FreeBSD Manual Pages
std::conditional(3) C++ Standard Libary std::conditional(3) NAME std::conditional - std::conditional Synopsis 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 types Member type Definition type T if B == true, F if B == false Helper types template< bool B, class T, class F > (since C++14) using conditional_t = typename conditional<B,T,F>::type; Possible implementation 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; }; Example // 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, dou- ble>::type Type3; std::cout << typeid(Type1).name() << '\n'; std::cout << typeid(Type2).name() << '\n'; std::cout << typeid(Type3).name() << '\n'; } Possible output: int double double See also enable_if conditionally removes a function overload or template spe- cialization from (C++11) overload resolution (class template) http://cppreference.com 2022.07.31 std::conditional(3)
NAME | Synopsis | Member types | Helper types | Possible implementation | Example | Possible output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::conditional&sektion=3&manpath=FreeBSD+Ports+15.0>
