What is a placeholder?
, , : - , . - , . ( - [ ], stand-ins -. , -.)
, , auto
decltype(auto)
:
auto i = 42;
auto& lref = i;
auto&& rref = 0;
decltype(auto) = 2 * i;
:
std::pair<auto, auto> p = std::make_pair(1, 4);
std::pair<auto, int> q = p;
, : :
template<typename Int>
concept bool Integral = …;
Integral a = 0;
Integral<> b = a;
template<typename Lhs, typename Rhs>
concept bool EqualityComparable = …;
EqualityComparable<double> c = a;
binary EqualityComparable
. , , , . , ( ) .
-, size()
. , size()
Incrementable
( - , Integral
).
template<typename Incr>
concept bool Incrementable = requires(Incr incr) {
++incr;
};
template<typename Cont>
concept bool Sizeable = requires(Cont const cont) {
{ cont.size() } -> Incrementable
};
№ 1 . , , --. , :
template<Incrementable Incr>
void valid_for_incrementable(Incr incr);
template<typename Cont>
concept bool Sizeable = requires(Cont const cont) {
cont.size();
valid_for_incrementable(cont.size());
};
, , : .
, :
template<typename T>
concept bool Demo = requires(T t) {
{ t } -> C<T>;
};
, C<T, T>
t
. placeholder C<int>
, C<T, int>
..