There is a bug in libstdc++, libc++, and MSVC's STL that causes it to ignore unused template parameter arguments in template aliases and does not cause substitution failures. This defect has been recorded here: http://open‐std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558.
Description
This causes the implementation of std::void_t to be buggy, as it is likely defined as something like the following:
template <typename...> using void_t = void;
This causes the compiler to ignore all the template arguments and does not help when one wants to cause substitution failures. Rather declarations which have void_t in orthogonal specializations are treated as the same. For example, assuming the possible T types are only allowed to have either the alias one or two and never both or none:
template <typename T, typename std::void_t<std::decay_t<T>::one>* = nullptr> void foo(T&&) {} template <typename T, typename std::void_t<std::decay_t<T>::two>* = nullptr> void foo(T&&) {}
The second foo() will be a redefinition because it conflicts with the first one; void_t does not cause substitution failures ‐ the template types are just ignored.
Types
Name |
Description |
A helper pairing an index with the type at that position. |
|
A helper collecting a type pack as a set of indexed types. |
|
A helper that recovers the type stored at a given index. |
|
A helper that exposes its first type argument, ignoring the rest. |
|
A helper mapping a bit width to the unsigned integer type of that width. |
|
A helper exposing the size and elements of a value list. |
|
A helper wrapping a single value as a type carrying that value. |
Type Aliases
Name |
Description |
A fallback implementation of type_pack_element_t without the builtin. |
|
An alias building the indexed‐type set for the pack T. |
Functions
Name |
Description |
Deduces the type identity of the Ith element of a type list. |
|
Deduces the size of a type list. |
Created with MrDocs