type_traits¶
Implementations of some type traits from C++17 and Lib Fundamentals v2 TS, and C++14-style type aliases for C++11.
-
template<class...>
usingtl::void_t= void¶ Turns any number of types into void.
This is useful as a metaprogramming trick.
-
template<template<class...> class
Trait, class ...Args>
usingtl::is_detected= magic¶ Checks if Trait<Args…> is a valid specialization. Implements std::experimental::is_detected from Lib Fundamentals V2 TS. Useful for detecting the presence of a given type member. Example:
template<class T> using make_cute_t = decltype(std::declval<T>().make_cute()); template<class T> using can_make_cute = tl::is_detected<make_cute_t, T>; struct cat{ void make_cute(); }; struct abstract_concept_of_fear{}; static_assert(can_make_cute<cat>::value); static_assert(!can_make_cute<abstract_concept_of_fear>::value);
-
template<typename
T>
usingtl::safe_underlying_type_t= magic¶ Like std::underlying_type, but if T is not an enum then there’s just no type member rather than being UB. Essentially implements P0340.
C++14-style alias templates¶
-
template<std::size_t
N, std::size_tAN>
usingtl::aligned_storage_t= typename std::aligned_storage<N, A>::type¶
-
template<std::size_t
N, class ...Ts>
usingtl::aligned_union_t= typename std::aligned_union<N, Ts...>::type¶