GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::type_identity(3) C++ Standard Libary std::type_identity(3)

std::type_identity - std::type_identity


Defined in header <type_traits>
template< class T > (since C++20)
struct type_identity;


Provides the member typedef type that names T (i.e., the identity transformation).


The behavior of a program that adds specializations for type_identity is undefined.


Name Definition
type T


template< class T > (since C++20)
using type_identity_t = typename type_identity<T>::type;


template< class T >
struct type_identity {
using type = T;
};


type_identity can be used to establish non-deduced contexts in template argument
deduction.


Feature-test macro: __cpp_lib_type_identity

// Run this code


#include <iostream>
#include <type_traits>


template <class T>
T foo(T a, T b) {
return a + b;
}


template <class T>
T bar(T a, std::type_identity_t<T> b) {
return a + b;
}


int main() {
// foo(4.2, 1); // error, deduced conflicting types for 'T'
std::cout << bar(4.2, 1) << '\n'; // OK, calls bar<double>
}


5.2

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.