| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++14) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <type_traits> | ||
template<class T,class U> struct reference_converts_from_temporary; | (since C++23) | |
LetV bestd::remove_cv_t<U> ifU is a scalar type orcv void, orU otherwise. IfT is a reference type, and given a hypothetical expressione such thatdecltype(e) isV, the variable definitionT ref= e; is well-formed andbinds a temporary object toref, then provides the member constantvalue equal totrue. Otherwise,value isfalse.
IfT is an lvalue reference type to a const- but not volatile-qualified object type or an rvalue reference type, bothstd::remove_reference_t<T> andstd::remove_reference_t<U> shall becomplete types,cvvoid, or anarrays of unknown bound; otherwise the behavior is undefined.
If an instantiation of a template above depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed, the behavior is undefined.
If the program adds specializations forstd::reference_converts_from_temporary orstd::reference_converts_from_temporary_v, the behavior is undefined.
Contents |
template<class T,class U> inlineconstexprbool reference_converts_from_temporary_v= | (since C++23) | |
value [static] | true ifT is a reference type, aU value can be bound toT in copy-initialization, and a temporary object would be bound to the reference,false otherwise(public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
std::reference_converts_from_temporary can be used for rejecting some cases that always produce dangling references.
#include <type_traits> int main(){} static_assert( std::reference_converts_from_temporary_v<int&&,int>==true&& std::reference_converts_from_temporary_v<constint&,int>==true&& std::reference_converts_from_temporary_v<int&&,int&&>==false&& std::reference_converts_from_temporary_v<constint&,int&&>==false&& std::reference_converts_from_temporary_v<int&&,long&&>==true&& std::reference_converts_from_temporary_v<int&&,long>==true);
(C++11)(C++20) | checks if a type can be converted to the other type (class template)[edit] |
(C++17)(C++23) | invokes anyCallable object with given argumentsand possibility to specify return type(since C++23) (function template)[edit] |
(C++11) | binds one or more arguments to a function object (function template)[edit] |
(C++17) | calls the provided functor with the arguments held by one or morevariants(function template)[edit] |
constructs a newstd::function instance(public member function of std::function<R(Args...)>)[edit] | |
constructs a newstd::move_only_function object(public member function of std::move_only_function)[edit] | |
| constructs the task object (public member function of std::packaged_task<R(Args...)>)[edit] |