Home > OS >  Will there be a standard typelist?
Will there be a standard typelist?

Time:01-28

Why isn't there a standard typelist in the C standard? I would think that something so useful for generic programming (as shown in reflection's ObjectSequence) would be a good candidate for standardization, instead of the myriad implementations around. Are there plans to add one?

CodePudding user response:

N3416: Packaging Parameter Packs proposed a language typelist, but is dead in the water since a decade back.

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 proposed introducing

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

But the main scope of the paper is bringing many common Boost meta-programming library types into the standard, where a type list is an essential helper, but where e.g. std::tuple could likewise be used as opposed to a dedicated type.

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).

However, the author mentioned in Cpplang Slack that this paper was rejected.

CodePudding user response:

Will there be a standard typelist?

If someone proposes it, and it is voted in by the committee, then there will be.

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

Either because it hasn't been proposed, or because such proposal hasn't been voted in by the committee (yet).

You can find the proposals here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/

  •  Tags:  
  • Related