types: add the convert
trait
This unconditionally replaces the first argument with the second. It can be useful when dealing with parameter packs.
This commit is contained in:
parent
0ded941de6
commit
85a502774c
16
types.hpp
16
types.hpp
@ -161,4 +161,20 @@ namespace cruft {
|
|||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename ValueT>
|
template <typename ValueT>
|
||||||
constexpr auto has_native_v = has_native<ValueT>::value;
|
constexpr auto has_native_v = has_native<ValueT>::value;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Unconditionally ignore the first argument, and store the second as `type`.
|
||||||
|
///
|
||||||
|
/// This aids converting parameter packs types. eg, converting all types
|
||||||
|
/// to strings by using an expression of the form:
|
||||||
|
/// `convert_t<ValueT, std::string>...`
|
||||||
|
template <typename IgnoredT, typename ResultT>
|
||||||
|
struct convert {
|
||||||
|
using type = ResultT;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename IgnoredT, typename ResultT>
|
||||||
|
using convert_t = typename convert<IgnoredT, ResultT>::type;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user