Во время CppCon2014 conference talk Уолтером Э. Брауном он утверждает, что в C++ описаны типы типов, описанных в стандарте.Каковы 15 типов типов в C++?
«15 разделов вселенной типов C++».
«void является одним из них». - Уолтер Э. Браун.
Что представляют собой другие 14?
Хотя копаться в стандарте, я обнаружил следующее:
// 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;
Хм, это больше, чем 15. Эти черты типа, так или иначе. Они используются для проверки определенных свойств типов во время компиляции. Например, тип integer
вернет значение для is_integral
, is_fundamental
и будет is_scalar
. Возможно, 15 из них перечислены выше, а остальные - подкатегории другим.
Вот моя попытка пытается сделать тип дерева языка:
Мое предположение:
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
Но также отметить, что bool
, char
и enum
все интегральные типы, поэтому я действительно не очень уверен в этом списке.
[ 'bool' и' char' являются неотъемлемыми типы] (http://ideone.com/cbP0G7). –
Возможно, вам стоит попросить Уолтера Э. Брауна? Что бы он ни говорил, это не то, что конкретно указано в спецификации языка C++. –
функция? совокупность? pod? xvalue? glvalue? буквально? constexpr? .... –