Namespaces
Variants

std:: reference_constructs_from_temporary

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더 파일에 정의됨 <type_traits>
template < class T, class U >
struct reference_constructs_from_temporary ;
(C++23부터)

U 가 스칼라 타입이거나 cv void 인 경우 V std:: remove_cv_t < U > 로 정의하고, 그렇지 않으면 V U 로 정의합니다. T 가 참조 타입이고, decltype ( e ) V 인 가상의 표현식 e 가 주어졌을 때, 변수 정의 T ref ( e ) ; 가 형식적으로 올바르며 임시 객체를 바인딩 하여 ref 에 연결한다면, 멤버 상수 value true 로 제공합니다. 그렇지 않으면 value false 입니다.

만약 T 가 const-이지만 volatile-한정되지 않은 객체 타입에 대한 lvalue 참조 타입이거나 rvalue 참조 타입인 경우, std:: remove_reference_t < T > std:: remove_reference_t < U > 는 모두 완전한 타입 이거나, cv void 이거나, 경계를 알 수 없는 배열 이어야 합니다; 그렇지 않으면 동작은 정의되지 않습니다.

템플릿의 인스턴스화가 직접적 또는 간접적으로 불완전한 타입에 의존하고, 해당 타입이 가상적으로 완성되었을 때 인스턴스화 결과가 달라질 수 있는 경우, 그 동작은 정의되지 않습니다.

프로그램이 std::reference_constructs_from_temporary 또는 std::reference_constructs_from_temporary_v 에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.

목차

헬퍼 변수 템플릿

template < class T, class U >

inline constexpr bool reference_constructs_from_temporary_v =

std :: reference_constructs_from_temporary < T, U > :: value ;
(C++23 이후)

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 T 가 참조 타입이고, U 값이 직접 초기화에서 T 에 바인딩될 수 있으며, 임시 객체가 참조에 바인딩될 경우. 그렇지 않으면 false
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

타입 정의
value_type bool
type std:: integral_constant < bool , value >

참고 사항

std::reference_constructs_from_temporary 는 항상 댕글링 참조를 생성하는 일부 경우를 거부하는 데 사용할 수 있습니다.

컴파일러가 CWG1696 을 구현한 경우, 멤버 초기화 리스트를 사용하여 임시 객체를 참조에 바인딩하는 것을 거부할 수도 있습니다.

예제

#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() {}

참고 항목

특정 인수들에 대한 생성자를 가지는지 확인합니다
(클래스 템플릿)
새로운 tuple 을 생성합니다
( std::tuple<Types...> 의 public 멤버 함수)
새로운 pair 를 생성합니다
( std::pair<T1,T2> 의 public 멤버 함수)
인수들의 튜플로 객체를 생성합니다
(함수 템플릿)