Created
September 20, 2018 22:11
-
-
Save cor3ntin/c104d9d95cedc3252374ee7a35dc8956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <stl2/concepts.hpp> | |
#include <stl2/iterator.hpp> | |
#include <stl2/ranges.hpp> | |
#include <vector> | |
#include <list> | |
#include <forward_list> | |
#include <string> | |
#include <string_view> | |
#include <deque> | |
#include <queue> | |
#include <set> | |
#include <map> | |
#include <unordered_map> | |
#include <unordered_set> | |
namespace std::experimental::ranges { | |
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>> | |
class basic_string : public std::basic_string<charT, traits, Allocator> { | |
using __b = std::basic_string<charT, traits, Allocator>; | |
public: | |
using __b::basic_string; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, charT> | |
explicit basic_string(Rng && rng, const Allocator & a = {}) | |
: __b(begin(rng),end(rng), a) {} | |
}; | |
template<class charT, class traits = char_traits<charT>> | |
class basic_string_view : public std::basic_string_view<charT, traits> { | |
using __b = std::basic_string_view<charT, traits>; | |
public: | |
using __b::basic_string_view; | |
template <ContiguousRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, charT> | |
// Probably do not need to be explicit ! | |
constexpr basic_string_view(const Rng & rng) | |
: __b(std::addressof(*begin(rng)),size(rng)) {} | |
}; | |
template <typename T, typename Allocator = std::allocator<T>> | |
class vector : public std::vector<T, Allocator> { | |
using __v = std::vector<T,Allocator>; | |
public: | |
using __v::vector; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, T> | |
explicit vector(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), a) {} | |
}; | |
template <typename T, typename Allocator = std::allocator<T>> | |
class deque : public std::deque<T, Allocator> { | |
using __v = std::deque<T,Allocator>; | |
public: | |
using __v::deque; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, T> | |
explicit deque(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), a) {} | |
}; | |
template <typename T, typename Allocator = std::allocator<T>> | |
class forward_list : public std::forward_list<T, Allocator> { | |
using __v = std::forward_list<T,Allocator>; | |
public: | |
using __v::forward_list; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, T> | |
explicit forward_list(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), a) {} | |
}; | |
template <typename T, typename Allocator = std::allocator<T>> | |
class list : public std::list<T, Allocator> { | |
using __v = std::list<T,Allocator>; | |
public: | |
using __v::list; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, T> | |
explicit list(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), a) {} | |
}; | |
template<class T, class Container = deque<T>> | |
class priority_queue : public std::priority_queue<T, Container> { | |
using __v = std::priority_queue<T,Container>; | |
public: | |
using __v::priority_queue; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, T> && !ConvertibleTo<Container,Rng> | |
explicit priority_queue(Rng && rng) | |
: __v(begin(rng),end(rng)) {} | |
template <InputRange Rng, typename Alloc> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, T> && !ConvertibleTo<Container,Rng> | |
explicit priority_queue(Rng && rng, const Alloc & a) | |
: __v(begin(rng),end(rng), a) {} | |
}; | |
// stack & queue do not have iterator-basd constructor. probably a reason ? | |
template<class Key, class T, class Compare = less<Key>, | |
class Allocator = allocator<pair<const Key, T>>> | |
class map : public std::map<Key, T, Compare, Allocator> { | |
using __v = std::map<Key, T, Compare, Allocator>; | |
public: | |
using __v::map; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, pair<const Key, T>> | |
explicit map(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), Compare(), a) {} | |
}; | |
template<class Key, class T, class Compare = less<Key>, | |
class Allocator = allocator<pair<const Key, T>>> | |
class multimap : public std::multimap<Key, T, Compare, Allocator> { | |
using __v = std::multimap<Key, T, Compare, Allocator>; | |
public: | |
using __v::multimap; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, pair<const Key, T>> | |
explicit multimap(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), Compare(), a) {} | |
}; | |
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> | |
class set : public std::set<Key, Compare, Allocator> { | |
using __v = std::set<Key, Compare, Allocator>; | |
public: | |
using __v::set; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, Key> | |
explicit set(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), Compare(), a) {} | |
}; | |
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> | |
class multiset : public std::multiset<Key, Compare, Allocator> { | |
using __v = std::multiset<Key, Compare, Allocator>; | |
public: | |
using __v::multiset; | |
template <InputRange Rng> | |
requires ConvertibleTo<iter_value_t<iterator_t<Rng>>, Key> | |
explicit multiset(Rng && rng, const Allocator & a = {}) | |
: __v(begin(rng),end(rng), Compare(), a) {} | |
}; | |
template <InputRange Rng, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
vector(Rng b, Allocator a = {}) -> vector<iter_value_t<iterator_t<Rng>>, Allocator>; | |
template <InputRange Rng, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
deque(Rng b, Allocator a = {}) -> deque<iter_value_t<iterator_t<Rng>>, Allocator>; | |
template <InputRange Rng, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
forward_list(Rng b, Allocator a = {}) -> forward_list<iter_value_t<iterator_t<Rng>>, Allocator>; | |
template <InputRange Rng, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
list(Rng b, Allocator a = {}) -> list<iter_value_t<iterator_t<Rng>>, Allocator>; | |
template <InputRange Rng, class Compare = std::less<typename iter_value_t <iterator_t< Rng>>::first_type>, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
map(Rng b, Compare = Compare(), Allocator = Allocator()) -> map< | |
typename iter_value_t <iterator_t< Rng>>::first_type, | |
typename iter_value_t <iterator_t< Rng>>::second_type, | |
Compare, | |
Allocator | |
>; | |
template <InputRange Rng, typename Allocator> | |
map(Rng b, Allocator = Allocator()) -> map< | |
typename iter_value_t <iterator_t< Rng>>::first_type, | |
typename iter_value_t <iterator_t< Rng>>::second_type, | |
Allocator | |
>; | |
template <InputRange Rng, class Compare = std::less<typename iter_value_t <iterator_t< Rng>>::first_type>, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
multimap(Rng b, Compare = Compare(), Allocator = Allocator()) -> multimap< | |
typename iter_value_t <iterator_t< Rng>>::first_type, | |
typename iter_value_t <iterator_t< Rng>>::second_type, | |
Compare, | |
Allocator | |
>; | |
template <InputRange Rng, typename Allocator> | |
multimap(Rng b, Allocator = Allocator()) -> multimap < | |
typename iter_value_t <iterator_t< Rng>>::first_type, | |
typename iter_value_t <iterator_t< Rng>>::second_type, | |
Allocator | |
>; | |
template <InputRange Rng, class Compare = std::less<iter_value_t<iterator_t< Rng>>>, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
set(Rng b, Compare = Compare(), Allocator = Allocator()) -> set< | |
iter_value_t <iterator_t< Rng>>, | |
Compare, | |
Allocator | |
>; | |
template <InputRange Rng, typename Allocator> | |
set(Rng b, Allocator = Allocator()) -> set < | |
iter_value_t <iterator_t< Rng>>, | |
Allocator | |
>; | |
template <InputRange Rng, class Compare = std::less<iter_value_t<iterator_t< Rng>>>, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
multiset(Rng b, Compare = Compare(), Allocator = Allocator()) -> multiset< | |
iter_value_t <iterator_t< Rng>>, | |
Compare, | |
Allocator | |
>; | |
template <InputRange Rng, typename Allocator> | |
multiset(Rng b, Allocator = Allocator()) -> multiset < | |
iter_value_t <iterator_t< Rng>>, | |
Allocator | |
>; | |
template <InputRange Rng> | |
priority_queue(Rng b) -> priority_queue<iter_value_t<iterator_t<Rng>>>; | |
template<InputRange Rng, typename Allocator = std::allocator<iter_value_t <iterator_t< Rng>>>> | |
basic_string(Rng b, Allocator a = {}) -> basic_string<iter_value_t<iterator_t<Rng>>, char_traits<iter_value_t<iterator_t<Rng>>>, Allocator>; | |
template<ContiguousRange Rng> | |
basic_string_view(Rng b) -> basic_string_view<iter_value_t<iterator_t<Rng>>, char_traits<iter_value_t<iterator_t<Rng>>>>; | |
using string = basic_string<char>; | |
using u16string = basic_string<char16_t>; | |
using u32string = basic_string<char32_t>; | |
using wstring = basic_string<wchar_t>; | |
using string_view = basic_string_view<char>; | |
using u16string_view = basic_string_view<char16_t>; | |
using u32string_view = basic_string_view<char32_t>; | |
using wstring_view = basic_string_view<wchar_t>; | |
} | |
namespace std2 = std::experimental::ranges; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment