From 85a502774c76e5d893a98826722574cfadd32850 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 7 Feb 2020 10:15:43 +1100 Subject: [PATCH] types: add the `convert` trait This unconditionally replaces the first argument with the second. It can be useful when dealing with parameter packs. --- types.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/types.hpp b/types.hpp index bbe676f9..6efe638c 100644 --- a/types.hpp +++ b/types.hpp @@ -161,4 +161,20 @@ namespace cruft { //------------------------------------------------------------------------- template constexpr auto has_native_v = has_native::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...` + template + struct convert { + using type = ResultT; + }; + + + template + using convert_t = typename convert::type; }