FreeBSD Manual Pages
std::refere...m_temporary(3) C++ Standard Libary std::refere...m_temporary(3) NAME std::reference_constructs_from_temporary - std::reference_con- structs_from_temporary Synopsis Defined in header <type_traits> template< class T, class U > (since C++23) struct reference_constructs_from_temporary; Let V be std::remove_cv_t<U> if U is a scalar type or cv void, or U otherwise. If T is a reference type, and given a hypothetic expression e such that decltype(e) is V, the variable definition T ref(e); is well-formed and binds a tempo- rary object to ref, then provides the member constant value equal to true. Other- wise, value is false. If T is an lvalue reference type to a const- but not volatile-quali- fied object type or an rvalue reference type, both std::remove_reference_t<T> and std::remove_reference_t<U> shall be complete types, cv void, or an arrays of unknown bound; otherwise the behavior is undefined. If an instantiation of a template above depends, directly or indi- rectly, on an incomplete type, and that instantiation could yield a different re- sult if that type were hypothetically completed, the behavior is undefined. If the program adds specializations for std::reference_con- structs_from_temporary or std::reference_constructs_from_temporary_v, the behavior is unde- fined. Member constants true if T is a reference type, a U value can be bound to T in value direct-initialization, and a temporary object would be bound to the [static] reference, false otherwise (public static member constant) Member functions operator bool converts the object to bool, returns value (public member function) operator() returns value (C++14) (public member function) Member types Type Definition value_type bool type std::integral_constant<bool, value> Notes std::reference_constructs_from_temporary can be used for rejecting some cases that always produce dangling references. It is also possible to use member initializer list to reject binding a temporary object to a reference if the compiler has implemented CWG1696. Example // Run this code #include <type_traits> static_assert(std::reference_constructs_from_temporary_v<int&&, int> == true); static_assert(std::reference_constructs_from_temporary_v<const int&, int> == true); static_assert(std::reference_constructs_from_temporary_v<int&&, int&&> == false); static_assert(std::reference_constructs_from_temporary_v<const int&, int&&> == false); static_assert(std::reference_constructs_from_temporary_v<int&&, long&&> == true); static_assert(std::reference_constructs_from_temporary_v<int&&, long> == true); int main() {} See also is_constructible is_trivially_constructible is_nothrow_constructible checks if a type has a constructor for specific arguments (C++11) (class template) (C++11) (C++11) constructor constructs a new tuple (public member function of std::tu- ple<Types...>) constructor constructs new pair (public member function of std::pair<T1,T2>) make_from_tuple construct an object with a tuple of argu- ments (C++17) (function template) http://cppreference.com 2024.06.10 std::refere...m_temporary(3)
NAME | Synopsis | Member constants | Member functions | Member types | Notes | Example | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::reference_constructs_from_temporary&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>
