Working Draft, Standard for Programming Language C++ (N4713, 2017 year) - page 21

 

  Главная      Manuals     Working Draft, Standard for Programming Language C++ (N4713, 2017 year)

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     19      20      21      22     ..

 

 

 

Working Draft, Standard for Programming Language C++ (N4713, 2017 year) - page 21

 

 

OUTERMOST_ALLOC_TRAITS(*this)::construct(
OUTERMOST(*this), p, std::forward<Args>(args)...)
(9.2)
Otherwise, if uses_allocator_v<T, inner_allocator_type> is true and is_constructible_-
v<T, allocator_arg_t, inner_allocator_type&, Args...> is true, calls:
OUTERMOST_ALLOC_TRAITS(*this)::construct(
OUTERMOST(*this), p, allocator_arg, inner_allocator(), std::forward<Args>(args)...)
(9.3)
Otherwise, if uses_allocator_v<T, inner_allocator_type> is true and is_constructible_-
v<T, Args..., inner_allocator_type&> is true, calls:
OUTERMOST_ALLOC_TRAITS(*this)::construct(
OUTERMOST(*this), p, std::forward<Args>(args)..., inner_allocator())
(9.4)
Otherwise, the program is ill-formed. [Note: An error will result if uses_allocator evaluates
to true but the specific constructor does not take an allocator. This definition prevents a silent
failure to pass an inner allocator to a contained element.
— end note ]
template<class T1, class T2, class... Args1, class... Args2>
void construct(pair<T1, T2>* p, piecewise_construct_t, tuple<Args1...> x, tuple<Args2...> y);
10
Requires: All of the types in Args1 and Args2 shall be CopyConstructible (Table 24).
11
Effects: Constructs a tuple object xprime from x by the following rules:
(11.1)
If uses_allocator_v<T1, inner_allocator_type> is false and is_constructible_v<T1,
Args1...> is true, then xprime is x.
(11.2)
Otherwise, if uses_allocator_v<T1, inner_allocator_type> is true and is_constructible_-
v<T1, allocator_arg_t, inner_allocator_type&, Args1...> is true, then xprime is:
tuple_cat(
tuple<allocator_arg_t, inner_allocator_type&>(allocator_arg, inner_allocator()),
std::move(x))
(11.3)
Otherwise, if uses_allocator_v<T1, inner_allocator_type> is true and is_constructible_-
v<T1, Args1..., inner_allocator_type&> is true, then xprime is:
tuple_cat(std::move(x), tuple<inner_allocator_type&>(inner_allocator()))
(11.4)
Otherwise, the program is ill-formed.
and constructs a tuple object yprime from y by the following rules:
(11.5)
If uses_allocator_v<T2, inner_allocator_type> is false and is_constructible_v<T2,
Args2...> is true, then yprime is y.
(11.6)
Otherwise, if uses_allocator_v<T2, inner_allocator_type> is true and is_constructible_-
v<T2, allocator_arg_t, inner_allocator_type&, Args2...> is true, then yprime is:
tuple_cat(
tuple<allocator_arg_t, inner_allocator_type&>(allocator_arg, inner_allocator()),
std::move(y))
(11.7)
Otherwise, if uses_allocator_v<T2, inner_allocator_type> is true and is_constructible_-
v<T2, Args2..., inner_allocator_type&> is true, then yprime is:
tuple_cat(std::move(y), tuple<inner_allocator_type&>(inner_allocator()))
(11.8)
Otherwise, the program is ill-formed.
then calls:
OUTERMOST_ALLOC_TRAITS(*this)::construct(
OUTERMOST(*this), p, piecewise_construct, std::move(xprime), std::move(yprime))
template<class T1, class T2>
void construct(pair<T1, T2>* p);
12
Effects: Equivalent to:
construct(p, piecewise_construct, tuple<>(), tuple<>());
§ 23.13.4
592
template<class T1, class T2, class U, class V>
void construct(pair<T1, T2>* p, U&& x, V&& y);
13
Effects: Equivalent to:
construct(p, piecewise_construct,
forward_as_tuple(std::forward<U>(x)),
forward_as_tuple(std::forward<V>(y)));
template<class T1, class T2, class U, class V>
void construct(pair<T1, T2>* p, const pair<U, V>& x);
14
Effects: Equivalent to:
construct(p, piecewise_construct,
forward_as_tuple(x.first),
forward_as_tuple(x.second));
template<class T1, class T2, class U, class V>
void construct(pair<T1, T2>* p, pair<U, V>&& x);
15
Effects: Equivalent to:
construct(p, piecewise_construct,
forward_as_tuple(std::forward<U>(x.first)),
forward_as_tuple(std::forward<V>(x.second)));
template<class T>
void destroy(T* p);
16
Effects: Calls OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this),
p).
scoped_allocator_adaptor select_on_container_copy_construction() const;
17
Returns: A new scoped_allocator_adaptor object where each allocator A in the adaptor is initialized
from the result of calling allocator_traits<A>::select_on_container_copy_construction() on
the corresponding allocator in *this.
23.13.5
Scoped allocator operators
[scoped.adaptor.operators]
template<class OuterA1, class OuterA2, class... InnerAllocs>
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
1
Returns: If sizeof...(InnerAllocs) is zero,
a.outer_allocator() == b.outer_allocator()
otherwise
a.outer_allocator() == b.outer_allocator() && a.inner_allocator() == b.inner_allocator()
template<class OuterA1, class OuterA2, class... InnerAllocs>
bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
2
Returns: !(a == b).
23.14
Function objects
[function.objects]
1
A function object type is an object type (6.7) that can be the type of the postfix-expression in a function call
(8.5.1.2, 16.3.1.1).226
A function object is an object of a function object type. In the places where one would
expect to pass a pointer to a function to an algorithmic template (Clause 28), the interface is specified to
accept a function object. This not only makes algorithmic templates work with pointers to functions, but
also enables them to work with arbitrary function objects.
226) Such a type is a function pointer or a class type which has a member operator() or a class type which has a conversion to
a pointer to function.
§ 23.14
593
23.14.1
Header <functional> synopsis
[functional.syn]
namespace std {
// 23.14.4, invoke
template<class F, class... Args>
invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
noexcept(is_nothrow_invocable_v<F, Args...>);
// 23.14.5, reference_wrapper
template<class T> class reference_wrapper;
template<class T> reference_wrapper<T> ref(T&) noexcept;
template<class T> reference_wrapper<const T> cref(const T&) noexcept;
template<class T> void ref(const T&&) = delete;
template<class T> void cref(const T&&) = delete;
template<class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
template<class T> reference_wrapper<const T> cref(reference_wrapper<T>)
noexcept;
// 23.14.6, arithmetic operations
template<class T = void> struct plus;
template<class T = void> struct minus;
template<class T = void> struct multiplies;
template<class T = void> struct divides;
template<class T = void> struct modulus;
template<class T = void> struct negate;
template<> struct plus<void>;
template<> struct minus<void>;
template<> struct multiplies<void>;
template<> struct divides<void>;
template<> struct modulus<void>;
template<> struct negate<void>;
// 23.14.7, comparisons
template<class T = void> struct equal_to;
template<class T = void> struct not_equal_to;
template<class T = void> struct greater;
template<class T = void> struct less;
template<class T = void> struct greater_equal;
template<class T = void> struct less_equal;
template<> struct equal_to<void>;
template<> struct not_equal_to<void>;
template<> struct greater<void>;
template<> struct less<void>;
template<> struct greater_equal<void>;
template<> struct less_equal<void>;
// 23.14.8, logical operations
template<class T = void> struct logical_and;
template<class T = void> struct logical_or;
template<class T = void> struct logical_not;
template<> struct logical_and<void>;
template<> struct logical_or<void>;
template<> struct logical_not<void>;
// 23.14.9, bitwise operations
template<class T = void> struct bit_and;
template<class T = void> struct bit_or;
template<class T = void> struct bit_xor;
template<class T = void> struct bit_not;
template<> struct bit_and<void>;
template<> struct bit_or<void>;
template<> struct bit_xor<void>;
template<> struct bit_not<void>;
§
23.14.1
594
// 23.14.10, function template not_fn
template<class F> unspecified not_fn(F&& f);
// 23.14.11, bind
template<class T> struct is_bind_expression;
template<class T> struct is_placeholder;
template<class F, class... BoundArgs>
unspecified bind(F&&, BoundArgs&&...);
template<class R, class F, class... BoundArgs>
unspecified bind(F&&, BoundArgs&&...);
namespace placeholders {
// M is the implementation-defined number of placeholders
see below _1;
see below _2;
see below _M;
}
// 23.14.12, member function adaptors
template<class R, class T>
unspecified mem_fn(R T::*) noexcept;
// 23.14.13, polymorphic function wrappers
class bad_function_call;
template<class> class function; // not defined
template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
template<class R, class... ArgTypes>
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
// 23.14.14, searchers
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
class default_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher;
// 23.14.15, hash function primary template
template<class T>
struct hash;
§ 23.14.1
595
// 23.14.11, function object binders
template<class T>
inline constexpr bool is_bind_expression_v = is_bind_expression<T>::value;
template<class T>
inline constexpr int is_placeholder_v = is_placeholder<T>::value;
}
1
[ Example: If a C++ program wants to have a by-element addition of two vectors a and b containing double
and put the result into a, it can do:
transform(a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
— end example ]
2
[ Example: To negate every element of a:
transform(a.begin(), a.end(), a.begin(), negate<double>());
— end example ]
23.14.2
Definitions
[func.def]
1
The following definitions apply to this Clause:
2
A call signature is the name of a return type followed by a parenthesized comma-separated list of zero or
more argument types.
3
A callable type is a function object type (23.14) or a pointer to member.
4
A callable object is an object of a callable type.
5
A call wrapper type is a type that holds a callable object and supports a call operation that forwards to that
object.
6
A call wrapper is an object of a call wrapper type.
7
A target object is the callable object held by a call wrapper.
23.14.3
Requirements
[func.require]
1
Define INVOKE(f, t1, t2, . . . , tN ) as follows:
(1.1)
(t1.*f)(t2, . . . , tN ) when f is a pointer to a member function of a class T and is_base_of_v<T,
remove_reference_t<decltype(t1)>> is true;
(1.2)
(t1.get().*f)(t2, . . . , tN ) when f is a pointer to a member function of a class T and remove_-
cvref_t<decltype(t1)> is a specialization of reference_wrapper;
(1.3)
((*t1).*f)(t2, . . . , tN ) when f is a pointer to a member function of a class T and t1 does not
satisfy the previous two items;
(1.4)
t1.*f when N == 1 and f is a pointer to data member of a class T and is_base_of_v<T, remove_-
reference_t<decltype(t1)>> is true;
(1.5)
t1.get().*f when N == 1 and f is a pointer to data member of a class T and remove_cvref_-
t<decltype(t1)> is a specialization of reference_wrapper;
(1.6)
(*t1).*f when N == 1 and f is a pointer to data member of a class T and t1 does not satisfy the
previous two items;
(1.7)
f(t1, t2, . . . , tN ) in all other cases.
2
Define INVOKE<R>(f, t1, t2, ..., tN ) as static_cast<void>(INVOKE(f, t1, t2, ..., tN )) if R is
cv void, otherwise INVOKE(f, t1, t2, . . . , tN ) implicitly converted to R.
3
Every call wrapper (23.14.2) shall be MoveConstructible. A forwarding call wrapper is a call wrapper that
can be called with an arbitrary argument list and delivers the arguments to the wrapped callable object as
references. This forwarding step shall ensure that rvalue arguments are delivered as rvalue references and
lvalue arguments are delivered as lvalue references. A simple call wrapper is a forwarding call wrapper that is
CopyConstructible and CopyAssignable and whose copy constructor, move constructor, copy assignment
operator, and move assignment operator do not throw exceptions.
[Note: In a typical implementation
forwarding call wrappers have an overloaded function call operator of the form
template<class... UnBoundArgs>
R operator()(UnBoundArgs&&... unbound_args) cv-qual ;
§ 23.14.3
596
— end note ]
23.14.4
Function template invoke
[func.invoke]
template<class F, class... Args>
invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
noexcept(is_nothrow_invocable_v<F, Args...>);
1
Returns: INVOKE(std::forward<F>(f), std::forward<Args>(args)...) (23.14.3).
23.14.5
Class template reference_wrapper
[refwrap]
namespace std {
template<class T> class reference_wrapper {
public:
// types
using type = T;
// construct/copy/destroy
template<class U>
reference_wrapper(U&&) noexcept(see below );
reference_wrapper(const reference_wrapper& x) noexcept;
// assignment
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
// access
operator T& () const noexcept;
T& get() const noexcept;
// invocation
template<class... ArgTypes>
invoke_result_t<T&, ArgTypes...> operator()(ArgTypes&&...) const;
};
template<class T>
reference_wrapper(T&) -> reference_wrapper<T>;
}
1
reference_wrapper<T> is a CopyConstructible and CopyAssignable wrapper around a reference to an
object or function of type T.
2
reference_wrapper<T> shall be a trivially copyable type (6.7).
23.14.5.1
reference_wrapper construct/copy/destroy
[refwrap.const]
template<class U>
reference_wrapper(U&& u) noexcept(see below );
1
Remarks: Let FUN denote the exposition-only functions
void FUN(T&) noexcept;
void FUN(T&&) = delete;
This constructor shall not participate in overload resolution unless the expression FUN(declval<U>())
is well-formed and is_same_v<decay_t<U>, reference_wrapper> is false. The expression inside
noexcept is equivalent to noexcept(FUN(declval<U>())).
2
Effects: Creates a variable r as if by T& r = std::forward<U>(u), then constructs a reference_-
wrapper object that stores a reference to r.
reference_wrapper(const reference_wrapper& x) noexcept;
3
Effects: Constructs a reference_wrapper object that stores a reference to x.get().
23.14.5.2
reference_wrapper assignment
[refwrap.assign]
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
1
Postconditions: *this stores a reference to x.get().
§ 23.14.5.2
597
23.14.5.3
reference_wrapper access
[refwrap.access]
operator T& () const noexcept;
1
Returns: The stored reference.
T& get() const noexcept;
2
Returns: The stored reference.
23.14.5.4
reference_wrapper invocation
[refwrap.invoke]
template<class... ArgTypes>
invoke_result_t<T&, ArgTypes...>
operator()(ArgTypes&&... args) const;
1
Returns: INVOKE(get(), std::forward<ArgTypes>(args)...). (23.14.3)
23.14.5.5
reference_wrapper helper functions
[refwrap.helpers]
template<class T> reference_wrapper<T> ref(T& t) noexcept;
1
Returns: reference_wrapper<T>(t).
template<class T> reference_wrapper<T> ref(reference_wrapper<T> t) noexcept;
2
Returns: ref(t.get()).
template<class T> reference_wrapper<const T> cref(const T& t) noexcept;
3
Returns: reference_wrapper <const T>(t).
template<class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
4
Returns: cref(t.get()).
23.14.6
Arithmetic operations
[arithmetic.operations]
1
The library provides basic function object classes for all of the arithmetic operators in the language (8.5.5,
8.5.6).
23.14.6.1
Class template plus
[arithmetic.operations.plus]
template<class T = void> struct plus {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x + y.
template<> struct plus<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) + std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) + std::forward<U>(u));
2
Returns: std::forward<T>(t) + std::forward<U>(u).
23.14.6.2
Class template minus
[arithmetic.operations.minus]
template<class T = void> struct minus {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x - y.
§ 23.14.6.2
598
template<> struct minus<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) - std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) - std::forward<U>(u));
2
Returns: std::forward<T>(t) - std::forward<U>(u).
23.14.6.3
Class template multiplies
[arithmetic.operations.multiplies]
template<class T = void> struct multiplies {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x * y.
template<> struct multiplies<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) * std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) * std::forward<U>(u));
2
Returns: std::forward<T>(t) * std::forward<U>(u).
23.14.6.4
Class template divides
[arithmetic.operations.divides]
template<class T = void> struct divides {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x / y.
template<> struct divides<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) / std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) / std::forward<U>(u));
2
Returns: std::forward<T>(t) / std::forward<U>(u).
23.14.6.5
Class template modulus
[arithmetic.operations.modulus]
template<class T = void> struct modulus {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x % y.
template<> struct modulus<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) % std::forward<U>(u));
§ 23.14.6.5
599
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t,
U&&
u)
const
-> decltype(std::forward<T>(t) % std::forward<U>(u));
2
Returns: std::forward<T>(t) % std::forward<U>(u).
23.14.6.6
Class template negate
[arithmetic.operations.negate]
template<class T = void> struct negate {
constexpr T operator()(const T& x) const;
};
constexpr T operator()(const T& x) const;
1
Returns: -x.
template<> struct negate<void> {
template<class T> constexpr auto operator()(T&& t) const
-> decltype(-std::forward<T>(t));
using is_transparent = unspecified ;
};
template<class T> constexpr auto operator()(T&& t) const
-> decltype(-std::forward<T>(t));
2
Returns: -std::forward<T>(t).
23.14.7
Comparisons
[comparisons]
1
The library provides basic function object classes for all of the comparison operators in the language (8.5.9,
8.5.10).
2
For templates less, greater, less_equal, and greater_equal, the specializations for any pointer type yield
a strict total order that is consistent among those specializations and is also consistent with the partial order
imposed by the built-in operators <, >, <=, >=. [ Note: When a < b is well-defined for pointers a and b of type
P, this implies (a < b) == less<P>(a, b), (a > b) == greater<P>(a, b), and so forth.
— end note ]
For template specializations less<void>, greater<void>, less_equal<void>, and greater_equal<void>,
if the call operator calls a built-in operator comparing pointers, the call operator yields a strict total order
that is consistent among those specializations and is also consistent with the partial order imposed by those
built-in operators.
23.14.7.1
Class template equal_to
[comparisons.equal_to]
template<class T = void> struct equal_to {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x == y.
template<> struct equal_to<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) == std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) == std::forward<U>(u));
2
Returns: std::forward<T>(t) == std::forward<U>(u).
§ 23.14.7.1
600
23.14.7.2
Class template not_equal_to
[comparisons.not_equal_to]
template<class T = void> struct not_equal_to {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x != y.
template<> struct not_equal_to<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) != std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) != std::forward<U>(u));
2
Returns: std::forward<T>(t) != std::forward<U>(u).
23.14.7.3
Class template greater
[comparisons.greater]
template<class T = void> struct greater {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x > y.
template<> struct greater<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) > std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) > std::forward<U>(u));
2
Returns: std::forward<T>(t) > std::forward<U>(u).
23.14.7.4
Class template less
[comparisons.less]
template<class T = void> struct less {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x < y.
template<> struct less<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) < std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) < std::forward<U>(u));
2
Returns: std::forward<T>(t) < std::forward<U>(u).
23.14.7.5
Class template greater_equal
[comparisons.greater_equal]
template<class T = void> struct greater_equal {
constexpr bool operator()(const T& x, const T& y) const;
§ 23.14.7.5
601
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x >= y.
template<> struct greater_equal<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) >= std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) >= std::forward<U>(u));
2
Returns: std::forward<T>(t) >= std::forward<U>(u).
23.14.7.6
Class template less_equal
[comparisons.less_equal]
template<class T = void> struct less_equal {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x <= y.
template<> struct less_equal<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) <= std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) <= std::forward<U>(u));
2
Returns: std::forward<T>(t) <= std::forward<U>(u).
23.14.8
Logical operations
[logical.operations]
1
The library provides basic function object classes for all of the logical operators in the language (8.5.14,
8.5.15, 8.5.2.1).
23.14.8.1
Class template logical_and
[logical.operations.and]
template<class T = void> struct logical_and {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x && y.
template<> struct logical_and<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) && std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) && std::forward<U>(u));
2
Returns: std::forward<T>(t) && std::forward<U>(u).
§ 23.14.8.1
602
23.14.8.2
Class template logical_or
[logical.operations.or]
template<class T = void> struct logical_or {
constexpr bool operator()(const T& x, const T& y) const;
};
constexpr bool operator()(const T& x, const T& y) const;
1
Returns: x || y.
template<> struct logical_or<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) || std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t,
U&& u) const
-> decltype(std::forward<T>(t) || std::forward<U>(u));
2
Returns: std::forward<T>(t) || std::forward<U>(u).
23.14.8.3
Class template logical_not
[logical.operations.not]
template<class T = void> struct logical_not {
constexpr bool operator()(const T& x) const;
};
constexpr bool operator()(const T& x) const;
1
Returns: !x.
template<> struct logical_not<void> {
template<class T> constexpr auto operator()(T&& t) const
-> decltype(!std::forward<T>(t));
using is_transparent = unspecified ;
};
template<class T> constexpr auto operator()(T&& t) const
-> decltype(!std::forward<T>(t));
2
Returns: !std::forward<T>(t).
23.14.9
Bitwise operations
[bitwise.operations]
1
The library provides basic function object classes for all of the bitwise operators in the language (8.5.11,
8.5.13, 8.5.12, 8.5.2.1).
23.14.9.1
Class template bit_and
[bitwise.operations.and]
template<class T = void> struct bit_and {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x & y.
template<> struct bit_and<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) & std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) & std::forward<U>(u));
2
Returns: std::forward<T>(t) & std::forward<U>(u).
§ 23.14.9.1
603
23.14.9.2
Class template bit_or
[bitwise.operations.or]
template<class T = void> struct bit_or {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x | y.
template<> struct bit_or<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) | std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) | std::forward<U>(u));
2
Returns: std::forward<T>(t) | std::forward<U>(u).
23.14.9.3
Class template bit_xor
[bitwise.operations.xor]
template<class T = void> struct bit_xor {
constexpr T operator()(const T& x, const T& y) const;
};
constexpr T operator()(const T& x, const T& y) const;
1
Returns: x ^ y.
template<> struct bit_xor<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) ^ std::forward<U>(u));
using is_transparent = unspecified ;
};
template<class T, class U> constexpr auto operator()(T&& t,
U&&
u)
const
-> decltype(std::forward<T>(t) ^ std::forward<U>(u));
2
Returns: std::forward<T>(t) ^ std::forward<U>(u).
23.14.9.4
Class template bit_not
[bitwise.operations.not]
template<class T = void> struct bit_not {
constexpr T operator()(const T& x) const;
};
constexpr T operator()(const T& x) const;
1
Returns: ~x.
template<> struct bit_not<void> {
template<class T> constexpr auto operator()(T&& t) const
-> decltype(~std::forward<T>(t));
using is_transparent = unspecified ;
};
template<class T> constexpr auto operator()(T&&) const
-> decltype(~std::forward<T>(t));
2
Returns: ~std::forward<T>(t).
§ 23.14.9.4
604
23.14.10
Function template not_fn
[func.not_fn]
template<class F> unspecified not_fn(F&& f);
1
Effects: Equivalent to: return call_wrapper (std::forward<F>(f)); where call_wrapper
is
an
exposition only class defined as follows:
class call_wrapper
{
using FD = decay_t<F>;
FD fd;
explicit call_wrapper (F&& f);
public:
call_wrapper (call_wrapper &&) = default;
call_wrapper (const call_wrapper &) = default;
template<class... Args>
auto operator()(Args&&...) &
-> decltype(!declval<invoke_result_t<FD&, Args...>>());
template<class... Args>
auto operator()(Args&&...) const&
-> decltype(!declval<invoke_result_t<const FD&, Args...>>());
template<class... Args>
auto operator()(Args&&...) &&
-> decltype(!declval<invoke_result_t<FD, Args...>>());
template<class... Args>
auto operator()(Args&&...) const&&
-> decltype(!declval<invoke_result_t<const FD, Args...>>());
};
explicit call_wrapper(F&& f);
2
Requires: FD shall satisfy the requirements of MoveConstructible. is_constructible_v<FD,
F> shall
be true. fd shall be a callable object (23.14.2).
3
Effects: Initializes fd from std::forward<F>(f).
4
Throws: Any exception thrown by construction of fd.
template<class... Args>
auto operator()(Args&&... args) &
-> decltype(!declval<invoke_result_t<FD&, Args...>>());
template<class... Args>
auto operator()(Args&&... args) const&
-> decltype(!declval<invoke_result_t<const FD&, Args...>>());
5
Effects: Equivalent to:
return !INVOKE(fd, std::forward<Args>(args)...);
// see 23.14.3
template<class... Args>
auto operator()(Args&&... args) &&
-> decltype(!declval<invoke_result_t<FD, Args...>>());
template<class... Args>
auto operator()(Args&&... args) const&&
-> decltype(!declval<invoke_result_t<const FD, Args...>>());
6
Effects: Equivalent to:
return !INVOKE(std::move(fd), std::forward<Args>(args)...);
// see 23.14.3
23.14.11
Function object binders
[func.bind]
1
This subclause describes a uniform mechanism for binding arguments of callable objects.
§ 23.14.11
605
23.14.11.1
Class template is_bind_expression
[func.bind.isbind]
namespace std {
template<class T> struct is_bind_expression;
// see below
}
1
The class template is_bind_expression can be used to detect function objects generated by bind. The
function template bind uses is_bind_expression to detect subexpressions.
2
Instantiations of the is_bind_expression template shall meet the UnaryTypeTrait requirements (23.15.1).
The implementation shall provide a definition that has a base characteristic of true_type if T is a type
returned from bind, otherwise it shall have a base characteristic of false_type. A program may specialize
this template for a user-defined type T to have a base characteristic of true_type to indicate that T should
be treated as a subexpression in a bind call.
23.14.11.2
Class template is_placeholder
[func.bind.isplace]
namespace std {
template<class T> struct is_placeholder;
// see below
}
1
The class template is_placeholder can be used to detect the standard placeholders _1, _2, and so on. The
function template bind uses is_placeholder to detect placeholders.
2
Instantiations of the is_placeholder template shall meet the UnaryTypeTrait requirements (23.15.1). The
implementation shall provide a definition that has the base characteristic of integral_constant<int, J >
if T is the type of std::placeholders::_J , otherwise it shall have a base characteristic of integral_-
constant<int, 0>. A program may specialize this template for a user-defined type T to have a base
characteristic of integral_constant<int, N> with N > 0 to indicate that T should be treated as a place-
holder type.
23.14.11.3
Function template bind
[func.bind.bind]
1
In the text that follows:
(1.1)
FD is the type decay_t<F>,
(1.2)
fd is an lvalue of type FD constructed from std::forward<F>(f),
(1.3)
Ti is the ith type in the template parameter pack BoundArgs,
(1.4)
TDi is the type decay_t<Ti>,
(1.5)
ti is the ith argument in the function parameter pack bound_args,
(1.6)
tdi is an lvalue of type TDi constructed from std::forward<Ti>(ti),
(1.7)
Uj is the jth deduced type of the UnBoundArgs&&... parameter of the forwarding call wrapper, and
(1.8)
uj is the jth argument associated with Uj.
template<class F, class... BoundArgs>
unspecified bind(F&& f, BoundArgs&&... bound_args);
2
Requires: is_constructible_v<FD, F> shall be true. For each Ti in BoundArgs, is_constructible_-
v<TDi, Ti> shall be true. INVOKE(fd, w1, w2, . . . , wN ) (23.14.3) shall be a valid expression for
some values w1, w2, ..., wN , where N has the value sizeof...(bound_args). The cv-qualifiers cv of
the call wrapper g, as specified below, shall be neither volatile nor const volatile.
3
Returns: A forwarding call wrapper g (23.14.3). The effect of g(u1, u2, . . . , uM ) shall be
INVOKE(fd, std::forward<V1>(v1), std::forward<V2>(v2), . . . , std::forward<VN >(vN ))
where the values and types of the bound arguments v1, v2, . . . , vN are determined as specified below.
The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if
and only if the corresponding constructor of FD or of any of the types TDi throws an exception.
4
Throws: Nothing unless the construction of fd or of one of the values tdi throws an exception.
5
Remarks: The return type shall satisfy the requirements of MoveConstructible. If all of FD and TDi
satisfy the requirements of CopyConstructible, then the return type shall satisfy the requirements
of CopyConstructible. [Note: This implies that all of FD and TDi are MoveConstructible.
— end
note ]
§ 23.14.11.3
606
template<class R, class F, class... BoundArgs>
unspecified bind(F&& f, BoundArgs&&... bound_args);
6
Requires: is_constructible_v<FD, F> shall be true. For each Ti in BoundArgs, is_constructible_-
v<TDi, Ti> shall be true. INVOKE(fd, w1, w2, . . . , wN ) shall be a valid expression for some values
w1, w2, ..., wN , where N has the value sizeof...(bound_args). The cv-qualifiers cv of the call
wrapper g, as specified below, shall be neither volatile nor const volatile.
7
Returns: A forwarding call wrapper g (23.14.3). The effect of g(u1, u2, . . . , uM ) shall be
INVOKE<R>(fd, std::forward<V1>(v1), std::forward<V2>(v2), . . . , std::forward<VN >(vN ))
where the values and types of the bound arguments v1, v2, . . . , vN are determined as specified below.
The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if
and only if the corresponding constructor of FD or of any of the types TDi throws an exception.
8
Throws: Nothing unless the construction of fd or of one of the values tdi throws an exception.
9
Remarks: The return type shall satisfy the requirements of MoveConstructible. If all of FD and TDi
satisfy the requirements of CopyConstructible, then the return type shall satisfy the requirements
of CopyConstructible. [Note: This implies that all of FD and TDi are MoveConstructible.
— end
note ]
10
The values of the bound arguments v1, v2, . . . , vN and their corresponding types V1, V2, . . . , VN depend on
the types TDi derived from the call to bind and the cv-qualifiers cv of the call wrapper g as follows:
(10.1)
if TDi is reference_wrapper<T>, the argument is tdi.get() and its type Vi is T&;
(10.2)
if the value of is_bind_expression_v<TDi> is true, the argument is tdi(std::forward<Uj >(uj )...)
and its type Vi is invoke_result_t<TDi cv &, Uj ...>&&;
(10.3)
if the value j of is_placeholder_v<TDi> is not zero, the argument is std::forward<Uj >(uj ) and its
type Vi is Uj &&;
(10.4)
otherwise, the value is tdi and its type Vi is TDi cv &.
23.14.11.4
Placeholders
[func.bind.place]
namespace std::placeholders {
// M is the implementation-defined number of placeholders
see below
_1;
see below
_2;
see below
_M;
}
1
All placeholder types shall be DefaultConstructible and CopyConstructible, and their default con-
structors and copy/move constructors shall not throw exceptions. It is implementation-defined whether
placeholder types are CopyAssignable. CopyAssignable placeholders’ copy assignment operators shall not
throw exceptions.
2
Placeholders should be defined as:
inline constexpr unspecified
_1{};
If they are not, they shall be declared as:
extern unspecified
_1;
23.14.12
Function template mem_fn
[func.memfn]
template<class R, class T> unspecified mem_fn(R T::* pm) noexcept;
1
Returns: A simple call wrapper (23.14.2) fn such that the expression fn(t, a2, . . . , aN ) is equivalent
to INVOKE(pm, t, a2, . . . , aN ) (23.14.3).
23.14.13
Polymorphic function wrappers
[func.wrap]
1
This subclause describes a polymorphic wrapper class that encapsulates arbitrary callable objects.
§ 23.14.13
607
23.14.13.1
Class bad_function_call
[func.wrap.badcall]
1
An exception of type bad_function_call is thrown by function::operator() (23.14.13.2.4) when the
function wrapper object has no target.
namespace std {
class bad_function_call : public exception {
public:
// 23.14.13.1.1, constructor
bad_function_call() noexcept;
};
}
23.14.13.1.1
bad_function_call constructor
[func.wrap.badcall.const]
bad_function_call() noexcept;
1
Effects: Constructs a bad_function_call object.
2
Postconditions: what() returns an implementation-defined ntbs.
23.14.13.2
Class template function
[func.wrap.func]
namespace std {
template<class> class function; // not defined
template<class R, class... ArgTypes>
class function<R(ArgTypes...)> {
public:
using result_type = R;
// 23.14.13.2.1, construct/copy/destroy
function() noexcept;
function(nullptr_t) noexcept;
function(const function&);
function(function&&);
template<class F> function(F);
function& operator=(const function&);
function& operator=(function&&);
function& operator=(nullptr_t) noexcept;
template<class F> function& operator=(F&&);
template<class F> function& operator=(reference_wrapper<F>)
noexcept;
~function();
// 23.14.13.2.2, function modifiers
void swap(function&) noexcept;
// 23.14.13.2.3, function capacity
explicit operator bool() const noexcept;
// 23.14.13.2.4, function invocation
R operator()(ArgTypes...) const;
// 23.14.13.2.5, function target access
const type_info& target_type() const noexcept;
template<class T>
T* target() noexcept;
template<class T> const T* target() const noexcept;
};
template<class R, class... ArgTypes>
function(R(*)(ArgTypes...)) -> function<R(ArgTypes...)>;
template<class F> function(F) -> function<see below >;
§ 23.14.13.2
608
// 23.14.13.2.6, Null pointer comparisons
template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
template<class R, class... ArgTypes>
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
// 23.14.13.2.7, specialized algorithms
template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
}
1
The function class template provides polymorphic wrappers that generalize the notion of a function pointer.
Wrappers can store, copy, and call arbitrary callable objects (23.14.2), given a call signature (23.14.2),
allowing functions to be first-class objects.
2
A callable type (23.14.2) F is Lvalue-Callable for argument types ArgTypes and return type R if the expression
INVOKE<R>(declval<F&>(), declval<ArgTypes>()...), considered as an unevaluated operand (8.2), is
well-formed (23.14.3).
3
The function class template is a call wrapper (23.14.2) whose call signature (23.14.2) is R(ArgTypes...).
4
[Note: The types deduced by the deduction guides for function may change in future versions of this
International Standard.
— end note ]
23.14.13.2.1
function construct/copy/destroy
[func.wrap.func.con]
function() noexcept;
1
Postconditions: !*this.
function(nullptr_t) noexcept;
2
Postconditions: !*this.
function(const function& f);
3
Postconditions: !*this if !f; otherwise, *this targets a copy of f.target().
4
Throws: Shall not throw exceptions if f’s target is a specialization of reference_wrapper or a function
pointer. Otherwise, may throw bad_alloc or any exception thrown by the copy constructor of the
stored callable object. [ Note: Implementations should avoid the use of dynamically allocated memory
for small callable objects, for example, where f’s target is an object holding only a pointer or reference
to an object and a member function pointer.
— end note ]
function(function&& f);
5
Postconditions: If !f, *this has no target; otherwise, the target of *this is equivalent to the target of
f before the construction, and f is in a valid state with an unspecified value.
6
Throws: Shall not throw exceptions if f’s target is a specialization of reference_wrapper or a function
pointer. Otherwise, may throw bad_alloc or any exception thrown by the copy or move constructor
of the stored callable object. [Note: Implementations should avoid the use of dynamically allocated
memory for small callable objects, for example, where f’s target is an object holding only a pointer or
reference to an object and a member function pointer.
— end note ]
template<class F> function(F f);
7
Requires: F shall be CopyConstructible.
8
Remarks: This constructor template shall not participate in overload resolution unless F is Lvalue-
Callable (23.14.13.2) for argument types ArgTypes... and return type R.
9
Postconditions: !*this if any of the following hold:
§ 23.14.13.2.1
609
(9.1)
f is a null function pointer value.
(9.2)
f is a null member pointer value.
(9.3)
F is an instance of the function class template, and !f.
10
Otherwise, *this targets a copy of f initialized with std::move(f). [Note: Implementations should
avoid the use of dynamically allocated memory for small callable objects, for example, where f is an
object holding only a pointer or reference to an object and a member function pointer.
— end note ]
11
Throws: Shall not throw exceptions when f is a function pointer or a reference_wrapper<T> for some
T. Otherwise, may throw bad_alloc or any exception thrown by F’s copy or move constructor.
template<class F> function(F) -> function<see below >;
12
Remarks: This deduction guide participates in overload resolution only if &F::operator() is well-formed
when treated as an unevaluated operand. In that case, if decltype(&F::operator()) is of the form
R(G::*)(A...) cv &opt noexceptopt for a class type G, then the deduced type is function<R(A...)>.
13
[ Example:
void f() {
int i{5};
function g = [&](double) { return i; }; // deduces function<int(double)>
}
— end example ]
function& operator=(const function& f);
14
Effects: As if by function(f).swap(*this);
15
Returns: *this.
function& operator=(function&& f);
16
Effects: Replaces the target of *this with the target of f.
17
Returns: *this.
function& operator=(nullptr_t) noexcept;
18
Effects: If *this != nullptr, destroys the target of this.
19
Postconditions: !(*this).
20
Returns: *this.
template<class F> function& operator=(F&& f);
21
Effects: As if by: function(std::forward<F>(f)).swap(*this);
22
Returns: *this.
23
Remarks: This assignment operator shall not participate in overload resolution unless decay_t<F> is
Lvalue-Callable (23.14.13.2) for argument types ArgTypes... and return type R.
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
24
Effects: As if by: function(f).swap(*this);
25
Returns: *this.
~function();
26
Effects: If *this != nullptr, destroys the target of this.
23.14.13.2.2
function modifiers
[func.wrap.func.mod]
void swap(function& other) noexcept;
1
Effects: Interchanges the targets of *this and other.
23.14.13.2.3
function capacity
[func.wrap.func.cap]
explicit operator bool() const noexcept;
1
Returns: true if *this has a target, otherwise false.
§ 23.14.13.2.3
610
23.14.13.2.4
function invocation
[func.wrap.func.inv]
R operator()(ArgTypes... args) const;
1
Returns: INVOKE<R>(f, std::forward<ArgTypes>(args)...) (23.14.3), where f is the target object
(23.14.2) of *this.
2
Throws: bad_function_call if !*this; otherwise, any exception thrown by the wrapped callable
object.
23.14.13.2.5
function target access
[func.wrap.func.targ]
const type_info& target_type() const noexcept;
1
Returns: If *this has a target of type T, typeid(T); otherwise, typeid(void).
template<class T>
T* target() noexcept;
template<class T> const T* target() const noexcept;
2
Returns: If target_type() == typeid(T) a pointer to the stored function target; otherwise a null
pointer.
23.14.13.2.6
null pointer comparison functions
[func.wrap.func.nullptr]
template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>& f, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator==(nullptr_t, const function<R(ArgTypes...)>& f) noexcept;
1
Returns: !f.
template<class R, class... ArgTypes>
bool operator!=(const function<R(ArgTypes...)>& f, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator!=(nullptr_t, const function<R(ArgTypes...)>& f) noexcept;
2
Returns: (bool)f.
23.14.13.2.7
specialized algorithms
[func.wrap.func.alg]
template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>& f2) noexcept;
1
Effects: As if by: f1.swap(f2);
23.14.14
Searchers
[func.search]
1
This subclause provides function object types (23.14) for operations that search for a sequence [pat_first,
pat_last) in another sequence [first, last) that is provided to the object’s function call operator. The
first sequence (the pattern to be searched for) is provided to the object’s constructor, and the second (the
sequence to be searched) is provided to the function call operator.
2
Each specialization of a class template specified in this subclause 23.14.14 shall meet the CopyConstructible
and CopyAssignable requirements. Template parameters named
(2.1)
ForwardIterator,
(2.2)
ForwardIterator1,
(2.3)
ForwardIterator2,
(2.4)
RandomAccessIterator,
(2.5)
RandomAccessIterator1,
(2.6)
RandomAccessIterator2, and
(2.7)
BinaryPredicate
of templates specified in this subclause 23.14.14 shall meet the same requirements and semantics as specified
in 28.1. Template parameters named Hash shall meet the requirements as specified in 20.5.3.4.
3
The Boyer-Moore searcher implements the Boyer-Moore search algorithm. The Boyer-Moore-Horspool
searcher implements the Boyer-Moore-Horspool search algorithm. In general, the Boyer-Moore searcher will
use more memory and give better runtime performance than Boyer-Moore-Horspool.
§ 23.14.14
611
23.14.14.1
Class template default_searcher
[func.search.default]
template<class ForwardIterator1, class BinaryPredicate = equal_to<>>
class default_searcher {
public:
default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last,
BinaryPredicate pred = BinaryPredicate());
template<class ForwardIterator2>
pair<ForwardIterator2, ForwardIterator2>
operator()(ForwardIterator2 first, ForwardIterator2 last) const;
private:
ForwardIterator1 pat_first_;
// exposition only
ForwardIterator1 pat_last_;
// exposition only
BinaryPredicate pred_;
// exposition only
};
default_searcher(ForwardIterator pat_first, ForwardIterator pat_last,
BinaryPredicate pred = BinaryPredicate());
1
Effects: Constructs a default_searcher object, initializing pat_first_ with pat_first, pat_last_
with pat_last, and pred_ with pred.
2
Throws: Any exception thrown by the copy constructor of BinaryPredicate or ForwardIterator1.
template<class ForwardIterator2>
pair<ForwardIterator2, ForwardIterator2>
operator()(ForwardIterator2 first, ForwardIterator2 last) const;
3
Effects: Returns a pair of iterators i and j such that
(3.1)
i == search(first, last, pat_first_, pat_last_, pred_), and
(3.2)
if i
== last, then j == last, otherwise j == next(i, distance(pat_first_, pat_last_)).
23.14.14.2
Class template boyer_moore_searcher
[func.search.bm]
template<class RandomAccessIterator1,
class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_searcher {
public:
boyer_moore_searcher(RandomAccessIterator1 pat_first,
RandomAccessIterator1 pat_last,
Hash hf = Hash(),
BinaryPredicate pred = BinaryPredicate());
template<class RandomAccessIterator2>
pair<RandomAccessIterator2, RandomAccessIterator2>
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
private:
RandomAccessIterator1 pat_first_;
// exposition only
RandomAccessIterator1 pat_last_;
// exposition only
Hash hash_;
// exposition only
BinaryPredicate pred_;
// exposition only
};
boyer_moore_searcher(RandomAccessIterator1 pat_first,
RandomAccessIterator1 pat_last,
Hash hf = Hash(),
BinaryPredicate pred = BinaryPredicate());
1
Requires: The value type of RandomAccessIterator1 shall meet the DefaultConstructible require-
ments, the CopyConstructible requirements, and the CopyAssignable requirements.
2
Requires: For any two values A and B of the type iterator_traits<RandomAccessIterator1>::val-
ue_type, if pred(A, B) == true, then hf(A) == hf(B) shall be true.
§ 23.14.14.2
612
3
Effects: Constructs a boyer_moore_searcher object, initializing pat_first_ with pat_first, pat_-
last_ with pat_last, hash_ with hf, and pred_ with pred.
4
Throws: Any exception thrown by the copy constructor of RandomAccessIterator1, or by the default
constructor, copy constructor, or the copy assignment operator of the value type of RandomAccess-
Iterator1, or the copy constructor or operator() of BinaryPredicate or Hash. May throw bad_alloc
if additional memory needed for internal data structures cannot be allocated.
template<class RandomAccessIterator2>
pair<RandomAccessIterator2, RandomAccessIterator2>
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
5
Requires: RandomAccessIterator1 and RandomAccessIterator2 shall have the same value type.
6
Effects: Finds a subsequence of equal values in a sequence.
7
Returns: A pair of iterators i and j such that
(7.1)
i is the first iterator in the range [first, last - (pat_last_ - pat_first_)) such that for
every non-negative integer n less than pat_last_ - pat_first_ the following condition holds:
pred(*(i + n), *(pat_first_ + n)) != false, and
(7.2)
j == next(i, distance(pat_first_, pat_last_)).
Returns make_pair(first, first) if [pat_first_, pat_last_) is empty, otherwise returns make_-
pair(last, last) if no such iterator is found.
8
Complexity: At most (last - first) * (pat_last_ - pat_first_) applications of the predicate.
23.14.14.3
Class template boyer_moore_horspool_searcher
[func.search.bmh]
template<class RandomAccessIterator1,
class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher {
public:
boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
RandomAccessIterator1 pat_last,
Hash hf = Hash(),
BinaryPredicate pred = BinaryPredicate());
template<class RandomAccessIterator2>
pair<RandomAccessIterator2, RandomAccessIterator2>
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
private:
RandomAccessIterator1 pat_first_;
// exposition only
RandomAccessIterator1 pat_last_;
// exposition only
Hash hash_;
// exposition only
BinaryPredicate pred_;
// exposition only
};
boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
RandomAccessIterator1 pat_last,
Hash hf = Hash(),
BinaryPredicate pred = BinaryPredicate());
1
Requires: The value type of RandomAccessIterator1 shall meet the DefaultConstructible, Copy-
Constructible, and CopyAssignable requirements.
2
Requires: For any two values A and B of the type iterator_traits<RandomAccessIterator1>::val-
ue_type, if pred(A, B) == true, then hf(A) == hf(B) shall be true.
3
Effects: Constructs a boyer_moore_horspool_searcher object, initializing pat_first_ with pat_-
first, pat_last_ with pat_last, hash_ with hf, and pred_ with pred.
4
Throws: Any exception thrown by the copy constructor of RandomAccessIterator1, or by the default
constructor, copy constructor, or the copy assignment operator of the value type of RandomAccess-
Iterator1 or the copy constructor or operator() of BinaryPredicate or Hash. May throw bad_alloc
if additional memory needed for internal data structures cannot be allocated.
§ 23.14.14.3
613
template<class RandomAccessIterator2>
pair<RandomAccessIterator2, RandomAccessIterator2>
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
5
Requires: RandomAccessIterator1 and RandomAccessIterator2 shall have the same value type.
6
Effects: Finds a subsequence of equal values in a sequence.
7
Returns: A pair of iterators i and j such that
(7.1)
i is the first iterator i in the range [first, last - (pat_last_ - pat_first_)) such that for
every non-negative integer n less than pat_last_ - pat_first_ the following condition holds:
pred(*(i + n), *(pat_first_ + n)) != false, and
(7.2)
j == next(i, distance(pat_first_, pat_last_)).
Returns make_pair(first, first) if [pat_first_, pat_last_) is empty, otherwise returns make_-
pair(last, last) if no such iterator is found.
8
Complexity: At most (last - first) * (pat_last_ - pat_first_) applications of the predicate.
23.14.15
Class template hash
[unord.hash]
1
The unordered associative containers defined in 26.5 use specializations of the class template hash (23.14.1)
as the default hash function.
2
Each specialization of hash is either enabled or disabled, as described below. [ Note: Enabled specializations
meet the requirements of Hash, and disabled specializations do not.
— end note ] Each header that declares
the template hash provides enabled specializations of hash for nullptr_t and all cv-unqualified arithmetic,
enumeration, and pointer types. For any type Key for which neither the library nor the user provides an
explicit or partial specialization of the class template hash, hash<Key> is disabled.
3
If the library provides an explicit or partial specialization of hash<Key>, that specialization is enabled except
as noted otherwise, and its member functions are noexcept except as noted otherwise.
4
If H is a disabled specialization of hash, these values are false: is_default_constructible_v<H>, is_-
copy_constructible_v<H>, is_move_constructible_v<H>, is_copy_assignable_v<H>, and is_move_-
assignable_v<H>. Disabled specializations of hash are not function object types (23.14). [ Note: This means
that the specialization of hash exists, but any attempts to use it as a Hash will be ill-formed.
— end note ]
5
An enabled specialization hash<Key> will:
(5.1)
satisfy the Hash requirements (20.5.3.4), with Key as the function call argument type, the Default-
Constructible requirements (Table 22), the CopyAssignable requirements (Table 26),
(5.2)
be swappable (20.5.3.2) for lvalues,
(5.3)
satisfy the requirement that if k1 == k2 is true, h(k1) == h(k2) is also true, where h is an object of
type hash<Key> and k1 and k2 are objects of type Key;
(5.4)
satisfy the requirement that the expression h(k), where h is an object of type hash<Key> and k is an
object of type Key, shall not throw an exception unless hash<Key> is a user-defined specialization that
depends on at least one user-defined type.
23.15
Metaprogramming and type traits
[meta]
1
This subclause describes components used by C++ programs, particularly in templates, to support the widest
possible range of types, optimise template code usage, detect type related user errors, and perform type
inference and transformation at compile time. It includes type classification traits, type property inspection
traits, and type transformations. The type classification traits describe a complete taxonomy of all possible
C++ types, and state where in that taxonomy a given type belongs. The type property inspection traits allow
important characteristics of types or of combinations of types to be inspected. The type transformations
allow certain properties of types to be manipulated.
2
All functions specified in this subclause are signal-safe (21.11.4).
23.15.1
Requirements
[meta.rqmts]
1
A UnaryTypeTrait describes a property of a type. It shall be a class template that takes one template
type argument and, optionally, additional arguments that help define the property being described. It
shall be DefaultConstructible, CopyConstructible, and publicly and unambiguously derived, directly or
indirectly, from its base characteristic, which is a specialization of the template integral_constant (23.15.3),
§ 23.15.1
614
with the arguments to the template integral_constant determined by the requirements for the particular
property being described. The member names of the base characteristic shall not be hidden and shall be
unambiguously available in the UnaryTypeTrait.
2
A BinaryTypeTrait describes a relationship between two types. It shall be a class template that takes
two template type arguments and, optionally, additional arguments that help define the relationship being
described. It shall be DefaultConstructible, CopyConstructible, and publicly and unambiguously derived,
directly or indirectly, from its base characteristic, which is a specialization of the template integral_-
constant (23.15.3), with the arguments to the template integral_constant determined by the requirements
for the particular relationship being described. The member names of the base characteristic shall not be
hidden and shall be unambiguously available in the BinaryTypeTrait.
3
A TransformationTrait modifies a property of a type. It shall be a class template that takes one template
type argument and, optionally, additional arguments that help define the modification. It shall define a
publicly accessible nested type named type, which shall be a synonym for the modified type.
23.15.2
Header <type_traits> synopsis
[meta.type.synop]
namespace std {
// 23.15.3, helper class
template<class T, T v> struct integral_constant;
template<bool B>
using bool_constant = integral_constant<bool, B>;
using true_type
= bool_constant<true>;
using false_type = bool_constant<false>;
// 23.15.4.1, primary type categories
template<class T> struct
is_void;
template<class T> struct
is_null_pointer;
template<class T> struct
is_integral;
template<class T> struct
is_floating_point;
template<class T> struct
is_array;
template<class T> struct
is_pointer;
template<class T> struct
is_lvalue_reference;
template<class T> struct
is_rvalue_reference;
template<class T> struct
is_member_object_pointer;
template<class T> struct
is_member_function_pointer;
template<class T> struct
is_enum;
template<class T> struct
is_union;
template<class T> struct
is_class;
template<class T> struct
is_function;
// 23.15.4.2, composite type categories
template<class T> struct
is_reference;
template<class T> struct
is_arithmetic;
template<class T> struct
is_fundamental;
template<class T> struct
is_object;
template<class T> struct
is_scalar;
template<class T> struct
is_compound;
template<class T> struct
is_member_pointer;
// 23.15.4.3, type properties
template<class T> struct
is_const;
template<class T> struct
is_volatile;
template<class T> struct
is_trivial;
template<class T> struct
is_trivially_copyable;
template<class T> struct
is_standard_layout;
template<class T> struct
is_empty;
template<class T> struct
is_polymorphic;
template<class T> struct
is_abstract;
template<class T> struct
is_final;
template<class T> struct
is_aggregate;
§ 23.15.2
615
template<class
T>
struct is_signed;
template<class
T>
struct is_unsigned;
template<class
T,
class... Args> struct is_constructible;
template<class
T>
struct is_default_constructible;
template<class
T>
struct is_copy_constructible;
template<class
T>
struct is_move_constructible;
template<class
T,
class U> struct is_assignable;
template<class
T>
struct is_copy_assignable;
template<class
T>
struct is_move_assignable;
template<class
T,
class U> struct is_swappable_with;
template<class
T>
struct is_swappable;
template<class
T>
struct is_destructible;
template<class
T,
class... Args> struct is_trivially_constructible;
template<class
T>
struct is_trivially_default_constructible;
template<class
T>
struct is_trivially_copy_constructible;
template<class
T>
struct is_trivially_move_constructible;
template<class
T,
class U> struct is_trivially_assignable;
template<class
T>
struct is_trivially_copy_assignable;
template<class
T>
struct is_trivially_move_assignable;
template<class
T>
struct is_trivially_destructible;
template<class
T,
class... Args> struct is_nothrow_constructible;
template<class
T>
struct is_nothrow_default_constructible;
template<class
T>
struct is_nothrow_copy_constructible;
template<class
T>
struct is_nothrow_move_constructible;
template<class
T,
class U> struct is_nothrow_assignable;
template<class
T>
struct is_nothrow_copy_assignable;
template<class
T>
struct is_nothrow_move_assignable;
template<class
T,
class U> struct is_nothrow_swappable_with;
template<class
T>
struct is_nothrow_swappable;
template<class
T>
struct is_nothrow_destructible;
template<class
T>
struct has_virtual_destructor;
template<class
T>
struct has_unique_object_representations;
// 23.15.5, type property queries
template<class T> struct alignment_of;
template<class T> struct rank;
template<class T, unsigned I = 0> struct extent;
// 23.15.6, type relations
template<class T, class U> struct is_same;
template<class Base, class Derived> struct is_base_of;
template<class From, class To> struct is_convertible;
template<class Fn, class... ArgTypes> struct is_invocable;
template<class R, class Fn, class... ArgTypes> struct is_invocable_r;
template<class Fn, class... ArgTypes> struct is_nothrow_invocable;
template<class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
// 23.15.7.1, const-volatile modifications
template<class T> struct remove_const;
template<class T> struct remove_volatile;
§
23.15.2
616
template<class T> struct remove_cv;
template<class T> struct add_const;
template<class T> struct add_volatile;
template<class T> struct add_cv;
template<class T>
using remove_const_t
= typename remove_const<T>::type;
template<class T>
using remove_volatile_t = typename remove_volatile<T>::type;
template<class T>
using remove_cv_t
= typename remove_cv<T>::type;
template<class T>
using add_const_t
= typename add_const<T>::type;
template<class T>
using add_volatile_t
= typename add_volatile<T>::type;
template<class T>
using add_cv_t
= typename add_cv<T>::type;
// 23.15.7.2, reference modifications
template<class T> struct remove_reference;
template<class T> struct add_lvalue_reference;
template<class T> struct add_rvalue_reference;
template<class T>
using remove_reference_t
= typename remove_reference<T>::type;
template<class T>
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
template<class T>
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
// 23.15.7.3, sign modifications
template<class T> struct make_signed;
template<class T> struct make_unsigned;
template<class T>
using make_signed_t
= typename make_signed<T>::type;
template<class T>
using make_unsigned_t = typename make_unsigned<T>::type;
// 23.15.7.4, array modifications
template<class T> struct remove_extent;
template<class T> struct remove_all_extents;
template<class T>
using remove_extent_t
= typename remove_extent<T>::type;
template<class T>
using remove_all_extents_t = typename remove_all_extents<T>::type;
// 23.15.7.5, pointer modifications
template<class T> struct remove_pointer;
template<class T> struct add_pointer;
template<class T>
using remove_pointer_t = typename remove_pointer<T>::type;
template<class T>
using add_pointer_t
= typename add_pointer<T>::type;
// 23.15.7.6, other transformations
template<size_t Len, size_t Align = default-alignment > // see 23.15.7.6
struct aligned_storage;
template<size_t Len, class... Types> struct aligned_union;
template<class T> struct remove_cvref;
template<class T> struct decay;
template<bool, class T = void> struct enable_if;
§
23.15.2
617
template<bool, class T, class F> struct conditional;
template<class... T> struct common_type;
template<class T> struct underlying_type;
template<class Fn, class... ArgTypes> struct invoke_result;
template<size_t Len, size_t Align = default-alignment > // see 23.15.7.6
using aligned_storage_t = typename aligned_storage<Len, Align>::type;
template<size_t Len, class... Types>
using aligned_union_t
= typename aligned_union<Len, Types...>::type;
template<class T>
using remove_cvref_t
= typename remove_cvref<T>::type;
template<class T>
using decay_t
= typename decay<T>::type;
template<bool b, class T = void>
using enable_if_t
= typename enable_if<b, T>::type;
template<bool b, class T, class F>
using conditional_t
= typename conditional<b, T, F>::type;
template<class... T>
using common_type_t
= typename common_type<T...>::type;
template<class T>
using underlying_type_t = typename underlying_type<T>::type;
template<class Fn, class... ArgTypes>
using invoke_result_t
= typename invoke_result<Fn, ArgTypes...>::type;
template<class...>
using void_t
= void;
// 23.15.8, logical operator traits
template<class... B> struct conjunction;
template<class... B> struct disjunction;
template<class B> struct negation;
// 23.15.9, endian
enum class endian {
little = see below ,
big
= see below ,
native = see below
};
// 23.15.4.1, primary type categories
template<class T>
inline constexpr bool is_void_v = is_void<T>::value;
template<class T>
inline constexpr bool is_null_pointer_v = is_null_pointer<T>::value;
template<class T>
inline constexpr bool is_integral_v = is_integral<T>::value;
template<class T>
inline constexpr bool is_floating_point_v = is_floating_point<T>::value;
template<class T>
inline constexpr bool is_array_v = is_array<T>::value;
template<class T>
inline constexpr bool is_pointer_v = is_pointer<T>::value;
template<class T>
inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<T>::value;
template<class T>
inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<T>::value;
template<class T>
inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<T>::value;
template<class T>
inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<T>::value;
template<class T>
inline constexpr bool is_enum_v = is_enum<T>::value;
template<class T>
inline constexpr bool is_union_v = is_union<T>::value;
§
23.15.2
618
template<class T>
inline constexpr bool is_class_v = is_class<T>::value;
template<class T>
inline constexpr bool is_function_v = is_function<T>::value;
// 23.15.4.2, composite type categories
template<class T>
inline constexpr bool is_reference_v = is_reference<T>::value;
template<class T>
inline constexpr bool is_arithmetic_v = is_arithmetic<T>::value;
template<class T>
inline constexpr bool is_fundamental_v = is_fundamental<T>::value;
template<class T>
inline constexpr bool is_object_v = is_object<T>::value;
template<class T>
inline constexpr bool is_scalar_v = is_scalar<T>::value;
template<class T>
inline constexpr bool is_compound_v = is_compound<T>::value;
template<class T>
inline constexpr bool is_member_pointer_v = is_member_pointer<T>::value;
// 23.15.4.3, type properties
template<class T>
inline constexpr bool is_const_v = is_const<T>::value;
template<class T>
inline constexpr bool is_volatile_v = is_volatile<T>::value;
template<class T>
inline constexpr bool is_trivial_v = is_trivial<T>::value;
template<class T>
inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<T>::value;
template<class T>
inline constexpr bool is_standard_layout_v = is_standard_layout<T>::value;
template<class T>
inline constexpr bool is_empty_v = is_empty<T>::value;
template<class T>
inline constexpr bool is_polymorphic_v = is_polymorphic<T>::value;
template<class T>
inline constexpr bool is_abstract_v = is_abstract<T>::value;
template<class T>
inline constexpr bool is_final_v = is_final<T>::value;
template<class T>
inline constexpr bool is_aggregate_v = is_aggregate<T>::value;
template<class T>
inline constexpr bool is_signed_v = is_signed<T>::value;
template<class T>
inline constexpr bool is_unsigned_v = is_unsigned<T>::value;
template<class T, class... Args>
inline constexpr bool is_constructible_v = is_constructible<T, Args...>::value;
template<class T>
inline constexpr bool is_default_constructible_v = is_default_constructible<T>::value;
template<class T>
inline constexpr bool is_copy_constructible_v = is_copy_constructible<T>::value;
template<class T>
inline constexpr bool is_move_constructible_v = is_move_constructible<T>::value;
template<class T, class U>
inline constexpr bool is_assignable_v = is_assignable<T, U>::value;
template<class T>
inline constexpr bool is_copy_assignable_v = is_copy_assignable<T>::value;
template<class T>
inline constexpr bool is_move_assignable_v = is_move_assignable<T>::value;
template<class T, class U>
inline constexpr bool is_swappable_with_v = is_swappable_with<T, U>::value;
template<class T>
inline constexpr bool is_swappable_v = is_swappable<T>::value;
§
23.15.2
619
template<class T>
inline constexpr bool is_destructible_v = is_destructible<T>::value;
template<class T, class... Args>
inline constexpr bool is_trivially_constructible_v
= is_trivially_constructible<T, Args...>::value;
template<class T>
inline constexpr bool is_trivially_default_constructible_v
= is_trivially_default_constructible<T>::value;
template<class T>
inline constexpr bool is_trivially_copy_constructible_v
= is_trivially_copy_constructible<T>::value;
template<class T>
inline constexpr bool is_trivially_move_constructible_v
= is_trivially_move_constructible<T>::value;
template<class T, class U>
inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<T, U>::value;
template<class T>
inline constexpr bool is_trivially_copy_assignable_v
= is_trivially_copy_assignable<T>::value;
template<class T>
inline constexpr bool is_trivially_move_assignable_v
= is_trivially_move_assignable<T>::value;
template<class T>
inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<T>::value;
template<class T, class... Args>
inline constexpr bool is_nothrow_constructible_v
= is_nothrow_constructible<T, Args...>::value;
template<class T>
inline constexpr bool is_nothrow_default_constructible_v
= is_nothrow_default_constructible<T>::value;
template<class T>
inline constexpr bool is_nothrow_copy_constructible_v
= is_nothrow_copy_constructible<T>::value;
template<class T>
inline constexpr bool is_nothrow_move_constructible_v
= is_nothrow_move_constructible<T>::value;
template<class T, class U>
inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<T, U>::value;
template<class T>
inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<T>::value;
template<class T>
inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<T>::value;
template<class T, class U>
inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<T, U>::value;
template<class T>
inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<T>::value;
template<class T>
inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<T>::value;
template<class T>
inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<T>::value;
template<class T>
inline constexpr bool has_unique_object_representations_v
= has_unique_object_representations<T>::value;
// 23.15.5, type property queries
template<class T>
inline constexpr size_t alignment_of_v = alignment_of<T>::value;
template<class T>
inline constexpr size_t rank_v = rank<T>::value;
template<class T, unsigned I = 0>
inline constexpr size_t extent_v = extent<T, I>::value;
§ 23.15.2
620
// 23.15.6, type relations
template<class T, class U>
inline constexpr bool is_same_v = is_same<T, U>::value;
template<class Base, class Derived>
inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
template<class From, class To>
inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
template<class Fn, class... ArgTypes>
inline constexpr bool is_invocable_v = is_invocable<Fn, ArgTypes...>::value;
template<class R, class Fn, class... ArgTypes>
inline constexpr bool is_invocable_r_v = is_invocable_r<R, Fn, ArgTypes...>::value;
template<class Fn, class... ArgTypes>
inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<Fn, ArgTypes...>::value;
template<class R, class Fn, class... ArgTypes>
inline constexpr bool is_nothrow_invocable_r_v
= is_nothrow_invocable_r<R, Fn, ArgTypes...>::value;
// 23.15.8, logical operator traits
template<class... B>
inline constexpr bool conjunction_v = conjunction<B...>::value;
template<class... B>
inline constexpr bool disjunction_v = disjunction<B...>::value;
template<class B>
inline constexpr bool negation_v = negation<B>::value;
}
1
The behavior of a program that adds specializations for any of the templates defined in this subclause is
undefined unless otherwise specified.
2
Unless otherwise specified, an incomplete type may be used to instantiate a template in this subclause.
23.15.3
Helper classes
[meta.help]
namespace std {
template<class T, T v> struct integral_constant {
static constexpr T value = v;
using value_type = T;
using type = integral_constant<T, v>;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; }
};
}
1
The class template integral_constant, alias template bool_constant, and its associated typedef-names
true_type and false_type are used as base classes to define the interface for various type traits.
23.15.4
Unary type traits
[meta.unary]
1
This subclause contains templates that may be used to query the properties of a type at compile time.
2
Each of these templates shall be a UnaryTypeTrait (23.15.1) with a base characteristic of true_type if the
corresponding condition is true, otherwise false_type.
23.15.4.1
Primary type categories
[meta.unary.cat]
1
The primary type categories correspond to the descriptions given in subclause 6.7 of the C++ standard.
2
For any given type T, the result of applying one of these templates to T and to cv T shall yield the same
result.
3
[ Note: For any given type T, exactly one of the primary type categories has a value member that evaluates
to true.
— end note ]
§ 23.15.4.1
621

 

 

 

 

 

 

 

Content      ..     19      20      21      22     ..