Durante un CppCon2014 conference talk di Walter E. Brown, afferma che ci sono 15 classificazioni di tipi in C++ che descrive lo standard.Quali sono le 15 classificazioni dei tipi in C++?
"15 partizioni dell'universo di tipi C++."
"vuoto è uno di questi." - Walter E. Brown.
Quali sono gli altri 14?
Mentre scavare attraverso lo standard, ho trovato la seguente:
// 20.11.4.1
primary type categories:
template <class T> struct is_void;
template <class T> struct is_integral;
template <class T> struct is_floating_point;
template <class T> struct is_array;
template <class T> struct is_pointer;
template <class T> struct is_lvalue_reference;
template <class T> struct is_rvalue_reference;
template <class T> struct is_member_object_pointer;
template <class T> struct is_member_function_pointer;
template <class T> struct is_enum;
template <class T> struct is_union;
template <class T> struct is_class;
template <class T> struct is_function;
// 20.11.4.2
composite type categories:
template <class T> struct is_reference;
template <class T> struct is_arithmetic;
template <class T> struct is_fundamental;
template <class T> struct is_object;
template <class T> struct is_scalar;
template <class T> struct is_compound;
template <class T> struct is_member_pointer;
Hmm, che è più di 15. Questi sono di tipo tratti comunque. Sono usati per testare certe proprietà dei tipi in fase di compilazione. Ad esempio, un tipo integer
restituisce true per is_integral
, is_fundamental
ed è is_scalar
. Forse i 15 sono alcuni di quelli sopra elencati e il resto sono sottocategorie per gli altri.
Ecco il mio tentativo di cercare di fare un albero tipo di linguaggio:
mia ipotesi:
1. void
2. bool
3. char
4. nullptr
5. integral (signed)
6. integral (unsigned)
7. floating
8. enum
9. array
10. class
11. union
12. lvalue reference
13. rvalue reference
14. member object pointer
15. member function pointer
Ma anche notare che bool
, char
e enum
sono tutti tipi interi, quindi non sono molto fiducioso in questa lista.
[ '' bool' e char' sono tipi integrali] (http://ideone.com/cbP0G7). –
Forse dovresti chiedere a Walter E. Brown? Qualunque cosa stia parlando, non è qualcosa di specificamente specificato nelle specifiche del linguaggio C++. –
funzione? aggregato? pod? xvalore? glivalue? letterale? constexpr? .... –