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::conditional(3) C++ Standard Libary std::conditional(3)

std::conditional - std::conditional


Defined in header <type_traits>
template< bool B, class T, class F > (since C++11)
struct conditional;


Provides member typedef type, which is defined as T if B is true at compile time, or
as F if B is false.


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


Member type Definition
type T if B == true, F if B == false


template< bool B, class T, class F > (since C++14)
using conditional_t = typename conditional<B,T,F>::type;


template<bool B, class T, class F>
struct conditional { using type = T; };


template<class T, class F>
struct conditional<false, T, F> { using type = F; };

// Run this code


#include <iostream>
#include <type_traits>
#include <typeinfo>


int main()
{
typedef std::conditional<true, int, double>::type Type1;
typedef std::conditional<false, int, double>::type Type2;
typedef std::conditional<sizeof(int) >= sizeof(double), int, double>::type Type3;


std::cout << typeid(Type1).name() << '\n';
std::cout << typeid(Type2).name() << '\n';
std::cout << typeid(Type3).name() << '\n';
}


int
double
double


enable_if conditionally removes a function overload or template specialization from
(C++11) overload resolution
(class template)

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.