Skip to content

Commit c8e3374

Browse files
committed
P0220R1: memory resources (section 8), except for section 8.2 (shared_ptr and weak_ptr changes)
1 parent 3f98154 commit c8e3374

File tree

4 files changed

+1241
-11
lines changed

4 files changed

+1241
-11
lines changed

source/containers.tex

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,11 @@
24792479
template <class T, class Allocator>
24802480
void swap(deque<T, Allocator>& x, deque<T, Allocator>& y)
24812481
noexcept(noexcept(x.swap(y)));
2482+
2483+
namespace pmr {
2484+
template <class T>
2485+
using deque = std::deque<T,polymorphic_allocator<T>>;
2486+
}
24822487
}
24832488
\end{codeblock}
24842489

@@ -2507,6 +2512,11 @@
25072512
template <class T, class Allocator>
25082513
void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
25092514
noexcept(noexcept(x.swap(y)));
2515+
2516+
namespace pmr {
2517+
template <class T>
2518+
using forward_list = std::forward_list<T,polymorphic_allocator<T>>;
2519+
}
25102520
}
25112521
\end{codeblock}
25122522

@@ -2535,6 +2545,11 @@
25352545
template <class T, class Allocator>
25362546
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
25372547
noexcept(noexcept(x.swap(y)));
2548+
2549+
namespace pmr {
2550+
template <class T>
2551+
using list = std::list<T,polymorphic_allocator<T>>;
2552+
}
25382553
}
25392554
\end{codeblock}
25402555

@@ -2570,6 +2585,11 @@
25702585
// hash support
25712586
template <class T> struct hash;
25722587
template <class Allocator> struct hash<vector<bool, Allocator>>;
2588+
2589+
namespace pmr {
2590+
template <class T>
2591+
using vector = std::vector<T,polymorphic_allocator<T>>;
2592+
}
25732593
}
25742594
\end{codeblock}
25752595

@@ -5390,6 +5410,16 @@
53905410
void swap(multimap<Key, T, Compare, Allocator>& x,
53915411
multimap<Key, T, Compare, Allocator>& y)
53925412
noexcept(noexcept(x.swap(y)));
5413+
5414+
namespace pmr {
5415+
template <class Key, class T, class Compare = less<Key>>
5416+
using map = std::map<Key, T, Compare,
5417+
polymorphic_allocator<pair<const Key,T>>>;
5418+
5419+
template <class Key, class T, class Compare = less<Key>>
5420+
using multimap = std::multimap<Key, T, Compare,
5421+
polymorphic_allocator<pair<const Key,T>>>;
5422+
}
53935423
}
53945424
\end{codeblock}
53955425

@@ -5453,6 +5483,16 @@
54535483
void swap(multiset<Key, Compare, Allocator>& x,
54545484
multiset<Key, Compare, Allocator>& y)
54555485
noexcept(noexcept(x.swap(y)));
5486+
5487+
namespace pmr {
5488+
template <class Key, class Compare = less<Key>>
5489+
using set = std::set<Key, Compare,
5490+
polymorphic_allocator<Key>>;
5491+
5492+
template <class Key, class Compare = less<Key>>
5493+
using multiset = std::multiset<Key, Compare,
5494+
polymorphic_allocator<Key>>;
5495+
}
54565496
}
54575497
\end{codeblock}
54585498

@@ -6847,6 +6887,24 @@
68476887
template <class Key, class T, class Hash, class Pred, class Alloc>
68486888
bool operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& a,
68496889
const unordered_multimap<Key, T, Hash, Pred, Alloc>& b);
6890+
6891+
namespace pmr {
6892+
template <class Key,
6893+
class T,
6894+
class Hash = hash<Key>,
6895+
class Pred = equal_to<Key>>
6896+
using unordered_map =
6897+
std::unordered_map<Key, T, Hash, Pred,
6898+
polymorphic_allocator<pair<const Key,T>>>;
6899+
template <class Key,
6900+
class T,
6901+
class Hash = hash<Key>,
6902+
class Pred = equal_to<Key>>
6903+
using unordered_multimap =
6904+
std::unordered_multimap<Key, T, Hash, Pred,
6905+
polymorphic_allocator<pair<const Key,T>>>;
6906+
6907+
}
68506908
}
68516909
\end{codeblock}
68526910

@@ -6894,6 +6952,20 @@
68946952
template <class Key, class Hash, class Pred, class Alloc>
68956953
bool operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& a,
68966954
const unordered_multiset<Key, Hash, Pred, Alloc>& b);
6955+
6956+
namespace pmr {
6957+
template <class Key,
6958+
class Hash = hash<Key>,
6959+
class Pred = equal_to<Key>>
6960+
using unordered_set = std::unordered_set<Key, Hash, Pred,
6961+
polymorphic_allocator<Key>>;
6962+
6963+
template <class Key,
6964+
class Hash = hash<Key>,
6965+
class Pred = equal_to<Key>>
6966+
using unordered_multiset = std::unordered_multiset<Key, Hash, Pred,
6967+
polymorphic_allocator<Key>>;
6968+
}
68976969
}
68986970
\end{codeblock}
68996971

source/regex.tex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,18 @@
635635
typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
636636
typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
637637
typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
638+
639+
namespace pmr {
640+
template <class BidirectionalIterator>
641+
using match_results =
642+
std::match_results<BidirectionalIterator,
643+
polymorphic_allocator<sub_match<BidirectionalIterator>>>;
644+
645+
typedef match_results<const char*> cmatch;
646+
typedef match_results<const wchar_t*> wcmatch;
647+
typedef match_results<string::const_iterator> smatch;
648+
typedef match_results<wstring::const_iterator> wsmatch;
649+
}
638650
}
639651
\end{codeblock}
640652

source/strings.tex

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -801,17 +801,28 @@
801801
template <> struct hash<u32string>;
802802
template <> struct hash<wstring>;
803803

804-
inline namespace literals {
805-
inline namespace string_literals {
806-
807-
// \ref{basic.string.literals}, suffix for basic_string literals:
808-
string operator "" s(const char* str, size_t len);
809-
u16string operator "" s(const char16_t* str, size_t len);
810-
u32string operator "" s(const char32_t* str, size_t len);
811-
wstring operator "" s(const wchar_t* str, size_t len);
812-
813-
}
814-
}
804+
namespace pmr {
805+
template <class charT, class traits = char_traits<charT>>
806+
using basic_string =
807+
std::basic_string<charT, traits, polymorphic_allocator<charT>>;
808+
809+
typedef basic_string<char> string;
810+
typedef basic_string<char16_t> u16string;
811+
typedef basic_string<char32_t> u32string;
812+
typedef basic_string<wchar_t> wstring;
813+
}
814+
815+
inline namespace literals {
816+
inline namespace string_literals {
817+
818+
// \ref{basic.string.literals}, suffix for basic_string literals:
819+
string operator "" s(const char* str, size_t len);
820+
u16string operator "" s(const char16_t* str, size_t len);
821+
u32string operator "" s(const char32_t* str, size_t len);
822+
wstring operator "" s(const wchar_t* str, size_t len);
823+
824+
}
825+
}
815826
}
816827
\end{codeblock}
817828

0 commit comments

Comments
 (0)