Top "Typetraits" questions

Type traits are syntactic extensions that allow the developer to determine at compile time various characteristics of a type.

How to initialize a static std::unordered_map of a type trait?

Given the following type trait, how can I initialize Fields with some std::pairs? template <> struct ManagerDataTrait<…

c++ static-members template-specialization unordered-map typetraits
How does `is_base_of` work?

How does the following code work? typedef char (&yes)[1]; typedef char (&no)[2]; template <typename B, typename D&…

c++ templates overloading implicit-conversion typetraits
Difference between char and signed char in c++?

Consider the following code : #include <iostream> #include <type_traits> int main(int argc, char* argv[]) { std::…

c++ c++11 char signed typetraits
What is the difference between a trait and a policy?

I have a class whose behavior I am trying to configure. template<int ModeT, bool IsAsync, bool IsReentrant> …

c++ template-meta-programming typetraits policy-based-design
Disambiguate overloaded member function pointer being passed as template parameter

I am attempting to recreate the Observer pattern where I can perfectly forward parameters to a given member function of …

c++ templates c++11 typetraits
Check if two types are equal in C++

How to check if types are equal in C++11? std::uint32_t == unsigned; //#1 And another snippet template<typename T&…

c++ c++11 typetraits
‘is_trivially_copyable’ is not a member of ‘std’

My gcc version is 4.8.3 20140624. I can use is_pod, is_trivial, is_standard_layout, but fail when trying is_trivially_…

c++ c++11 typetraits
Why is there not an std::is_struct type trait?

I've seen that in order to check if a type T is a class I can use: bool isClass = std::…

c++ c++11 typetraits
Why is std::is_pod deprecated in C++20?

std::is_pod will be probably deprecated in C++20. What's the reason for this choice? What should I use in …

c++ typetraits
no type named ‘type’ in ‘struct std::enable_if<false, void>

Why does this not work? It is giving me an error error: no type named ‘type’ in ‘struct std::enable_…

c++ typetraits