std::meta::common_reference
| Defined in header <meta>
|
||
template< std::meta::reflection_range R = std::initializer_list<std::meta::info> >
consteval std::meta::info common_reference( R&& types );
|
(since C++26) | |
Let T... be a pack of types or type aliases whose elements are represented by the corresponding elements of types.
Determines the common reference type of a sequence of reflected types T..., that is, the type to which all the types in T... can be converted or bound. If such a type exists (as determined according to the rules for std::common_reference), returns the reflection of that type.
Equivalent to return std::meta::dealias(^^std::common_reference<T...>::type);, except that if the member type is not provided throws std::meta::exception.
When given reference types, common_reference attempts to find a reference type to which the supplied reference types can all be bound, but may return a non-reference type if it cannot find such a reference type.
If any type in the pack T... is not a complete type or (possibly cv-qualified) void, the program is ill-formed.
Parameters
| types | - | a range of reflected types |
Return value
A reflection of the common (maybe reference) type among all types T..., if such a type exists.
Exceptions
Throws std::meta::exception if
- any reflection in
typesdoes not represent a type or type alias; - no common (reference) type exists, as described above.
Example
#include <meta>
static_assert(
(std::meta::common_reference(
{
^^int&, ^^int&&, ^^const int&, ^^const int&&
})
== ^^const int&)
&&
(std::meta::common_reference(
{
^^short, ^^int&, ^^int&&, ^^const int&, ^^const int&&
})
== ^^int)
);
int main() {}
See also
(C++26) |
determines the common type of a sequence of reflected types (function template) |
(C++20) |
specifies that two types share a common reference type (concept) |
(C++20)(C++20) |
determines the common reference type of a group of types (class template) |