Skip to content

Commit 17576b3

Browse files
committed
Merge 2016-02 LWG Motion 6
Notably this does not merge the changes to shared_ptr and weak_ptr.
2 parents 014196a + 49d65e0 commit 17576b3

File tree

7 files changed

+7817
-3398
lines changed

7 files changed

+7817
-3398
lines changed

source/algorithms.tex

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@
245245
ForwardIterator2 first2, ForwardIterator2 last2,
246246
BinaryPredicate pred);
247247

248+
// \ref{alg.search}, search:
248249
template<class ForwardIterator1, class ForwardIterator2>
249250
ForwardIterator1 search(
250251
ForwardIterator1 first1, ForwardIterator1 last1,
@@ -284,6 +285,10 @@
284285
Size count, const T& value,
285286
BinaryPredicate pred);
286287

288+
template <class ForwardIterator, class Searcher>
289+
ForwardIterator search(ForwardIterator first, ForwardIterator last,
290+
const Searcher &searcher);
291+
287292
// \ref{alg.modifying.operations}, modifying sequence operations:
288293
// \ref{alg.copy}, copy:
289294
template<class InputIterator, class OutputIterator>
@@ -512,6 +517,13 @@
512517
ForwardIterator first, ForwardIterator middle,
513518
ForwardIterator last, OutputIterator result);
514519

520+
// \ref{alg.random.sample}, sample:
521+
template<class PopulationIterator, class SampleIterator,
522+
class Distance, class UniformRandomNumberGenerator>
523+
SampleIterator sample(PopulationIterator first, PopulationIterator last,
524+
SampleIterator out, Distance n,
525+
UniformRandomNumberGenerator&& g);
526+
515527
// \ref{alg.random.shuffle}, shuffle:
516528
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
517529
void shuffle(RandomAccessIterator first,
@@ -2081,6 +2093,24 @@
20812093
applications of the corresponding predicate.
20822094
\end{itemdescr}
20832095

2096+
\indexlibrary{\idxcode{search}}%
2097+
\begin{itemdecl}
2098+
template<class ForwardIterator, class Searcher>
2099+
ForwardIterator search(ForwardIterator first, ForwardIterator last,
2100+
const Searcher& searcher);
2101+
\end{itemdecl}
2102+
2103+
\begin{itemdescr}
2104+
\pnum
2105+
\effects
2106+
Equivalent to \tcode{return searcher(first, last);}
2107+
2108+
\pnum
2109+
\remarks
2110+
\tcode{Searcher} need not meet the \tcode{CopyConstructible} requirements.
2111+
\end{itemdescr}
2112+
2113+
20842114
\rSec1[alg.modifying.operations]{Mutating sequence operations}
20852115

20862116
\rSec2[alg.copy]{Copy}
@@ -2930,14 +2960,78 @@
29302960
assignments.
29312961
\end{itemdescr}
29322962

2963+
\rSec2[alg.random.sample]{Sample}
2964+
2965+
\indexlibrary{\idxcode{sample}}%
2966+
\begin{itemdecl}
2967+
template<class PopulationIterator, class SampleIterator,
2968+
class Distance, class UniformRandomNumberGenerator>
2969+
SampleIterator sample(PopulationIterator first, PopulationIterator last,
2970+
SampleIterator out, Distance n,
2971+
UniformRandomNumberGenerator&& g);
2972+
\end{itemdecl}
2973+
2974+
\begin{itemdescr}
2975+
\pnum
2976+
\requires
2977+
\begin{itemize}
2978+
\item
2979+
\tcode{PopulationIterator} shall meet the requirements of an \tcode{InputIterator} type.
2980+
\item
2981+
\tcode{SampleIterator} shall meet the requirements of an \tcode{OutputIterator} type.
2982+
\item
2983+
\tcode{SampleIterator} shall meet the additional requirements of a \tcode{RandomAccessIterator} type
2984+
unless \tcode{PopulationIterator} meets the additional requirements of a \tcode{ForwardIterator} type.
2985+
\item
2986+
\tcode{PopulationIterator}'s value type shall be writable to \tcode{out}.
2987+
\item
2988+
\tcode{Distance} shall be an integer type.
2989+
\item
2990+
\tcode{UniformRandomNumberGenerator} shall meet the requirements of a uniform random number generator type (\ref{rand.req.urng})
2991+
whose return type is convertible to \tcode{Distance}.
2992+
\item
2993+
\tcode{out} shall not be in the range \range{first}{last}.
2994+
\end{itemize}
2995+
2996+
\pnum
2997+
\effects
2998+
Copies \tcode{min(last - first, n)} elements (the \defn{sample})
2999+
from \range{first}{last} (the \defn{population}) to \tcode{out}
3000+
such that each possible sample has equal probability of appearance.
3001+
\enternote
3002+
Algorithms that obtain such effects include \term{selection sampling}
3003+
and \term{reservoir sampling}.
3004+
\exitnote
3005+
3006+
\pnum
3007+
\returns
3008+
The end of the resulting sample range.
3009+
3010+
\pnum
3011+
\complexity
3012+
O(\tcode{last - first}).
3013+
3014+
\pnum
3015+
\remarks
3016+
\begin{itemize}
3017+
\item
3018+
Stable if and only if \tcode{PopulationIterator} meets the
3019+
requirements of a \tcode{ForwardIterator} type.
3020+
\item
3021+
To the extent that the implementation of this function makes use of
3022+
random numbers, the object \tcode{g} shall serve as the
3023+
implementation's source of randomness.
3024+
\end{itemize}
3025+
\end{itemdescr}
3026+
29333027
\rSec2[alg.random.shuffle]{Shuffle}
29343028

29353029
\indexlibrary{\idxcode{shuffle}}%
29363030
\begin{itemdecl}
29373031
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
29383032
void shuffle(RandomAccessIterator first,
2939-
RandomAccessIterator last,
2940-
UniformRandomNumberGenerator&& g);
3033+
RandomAccessIterator last,
3034+
UniformRandomNumberGenerator&& g);
29413035
\end{itemdecl}
29423036

29433037
\begin{itemdescr}

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/lib-intro.tex

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@
966966

967967
\pnum
968968
The \Cpp standard library provides
969-
56
969+
60
970970
\term{\Cpp library headers},
971971
\indextext{header!C++ library}%
972972
as shown in Table~\ref{tab:cpp.library.headers}.
@@ -975,77 +975,76 @@
975975
{lllll}
976976
\topline
977977
\tcode{<algorithm>} &
978+
\tcode{<execution_policy>} &
979+
\tcode{<limits>} &
980+
\tcode{<random>} &
981+
\tcode{<strstream>} \\
982+
983+
\tcode{<any>} &
978984
\tcode{<forward_list>} &
979985
\tcode{<list>} &
980-
\tcode{<scoped_allocator>} &
981-
\tcode{<type_traits>} \\
986+
\tcode{<ratio>} &
987+
\tcode{<system_error>} \\
982988

983989
\tcode{<array>} &
984990
\tcode{<fstream>} &
985991
\tcode{<locale>} &
986-
\tcode{<set>} &
987-
\tcode{<typeindex>} \\
992+
\tcode{<regex>} &
993+
\tcode{<thread>} \\
988994

989995
\tcode{<atomic>} &
990996
\tcode{<functional>} &
991997
\tcode{<map>} &
992-
\tcode{<shared_mutex>} &
993-
\tcode{<typeinfo>} \\
998+
\tcode{<scoped_allocator>} &
999+
\tcode{<tuple>} \\
9941000

9951001
\tcode{<bitset>} &
9961002
\tcode{<future>} &
9971003
\tcode{<memory>} &
998-
\tcode{<sstream>} &
999-
\tcode{<unordered_map>} \\
1004+
\tcode{<set>} &
1005+
\tcode{<typeindex>} \\
10001006

10011007
\tcode{<chrono>} &
10021008
\tcode{<initializer_list>} &
1003-
\tcode{<mutex>} &
1004-
\tcode{<stack>} &
1005-
\tcode{<unordered_set>} \\
1009+
\tcode{<memory_resorce>} &
1010+
\tcode{<shared_mutex>} &
1011+
\tcode{<typeinfo>} \\
10061012

10071013
\tcode{<codecvt>} &
10081014
\tcode{<iomanip>} &
1009-
\tcode{<new>} &
1010-
\tcode{<stdexcept>} &
1011-
\tcode{<utility>} \\
1015+
\tcode{<mutex>} &
1016+
\tcode{<sstream>} &
1017+
\tcode{<type_traits>} \\
10121018

10131019
\tcode{<complex>} &
10141020
\tcode{<ios>} &
1015-
\tcode{<numeric>} &
1016-
\tcode{<streambuf>} &
1017-
\tcode{<valarray>} \\
1021+
\tcode{<new>} &
1022+
\tcode{<stack>} &
1023+
\tcode{<unordered_map>} \\
10181024

10191025
\tcode{<condition_variable>} &
10201026
\tcode{<iosfwd>} &
1021-
\tcode{<ostream>} &
1022-
\tcode{<string>} &
1023-
\tcode{<vector>} \\
1027+
\tcode{<numeric>} &
1028+
\tcode{<stdexcept>} &
1029+
\tcode{<unordered_set>} \\
10241030

10251031
\tcode{<deque>} &
10261032
\tcode{<iostream>} &
1027-
\tcode{<queue>} &
1028-
\tcode{<strstream>} &
1029-
\\
1033+
\tcode{<optional>} &
1034+
\tcode{<streambuf>} &
1035+
\tcode{<utility>} \\
10301036

10311037
\tcode{<exception>} &
10321038
\tcode{<istream>} &
1033-
\tcode{<random>} &
1034-
\tcode{<system_error>} &
1035-
\\
1039+
\tcode{<ostream>} &
1040+
\tcode{<string>} &
1041+
\tcode{<valarray>} \\
10361042

10371043
\tcode{<exception_list>} &
10381044
\tcode{<iterator>} &
1039-
\tcode{<ratio>} &
1040-
\tcode{<thread>} &
1041-
\\
1042-
1043-
\tcode{<execution_policy>} &
1044-
\tcode{<limits>} &
1045-
\tcode{<regex>} &
1046-
\tcode{<tuple>} &
1047-
\\
1048-
1045+
\tcode{<queue>} &
1046+
\tcode{<string_view>} &
1047+
\tcode{<vector>} \\
10491048
\end{floattable}
10501049

10511050

0 commit comments

Comments
 (0)