会有标准的类型列表吗?

Will there be a standard typelist?

为什么 C++ 标准中没有标准类型列表?我认为对泛型编程如此有用的东西(如反射的 ObjectSequence 所示)将是标准化的一个很好的候选者,而不是周围的无数实现。有计划加一个吗?

Will there be a standard typelist?

如果有人提出,委员会投票通过,就会有。

Why isn't there a standard typelist in the C++ standard?

要么是因为它还没有被提议,要么是因为这样的提议还没有被委员会投票通过。

您可以在此处找到提案:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/

N3416: Packaging Parameter Packs 提出了一个语言类型列表,但十年前就已经死了。

A parameter pack literal is a template-parameter-list (§14p1) surrounded by angle brackets, like

<int, std::basic_ostream<char>, 7>

To name a parameter list, we just typedef it, like

typedef<signed char, short int, int, long int, long long int> signed_integral_types;
cout << contains<signed_integral_types, int>::value; // Prints true

P1858: Generalized pack declaration and usage is more likely to provide the functionality of a standard type list, as a language feature in particular contexts. The paper is still under EWG discussion.


P0949: Adding support for type-based metaprogramming to the standard library提议引入

template<class... T> struct mp_list {};

但本文的主要范围是将许多常见的 Boost meta-programming 库类型纳入标准,其中类型列表是必不可少的帮助,但例如std::tuple 同样可以用来代替专用类型。

The fundamental data structure on which the proposed algorithms operate is the list, an instantiation of a class template whose parameters are all types. The library does not require or prefer a specific list type. While a canonical mp_list is supplied, its use is not mandatory; all operations and algorithms support other lists such as std::tuple, std::variant or even std::pair (when there is no need to add or remove elements).

不过作者在Cpplang Slack中提到这篇论文被拒