From 744e02fb01214c84b9487f3c135844fdc1b011e2 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Tue, 19 Oct 2021 22:28:45 -0400 Subject: [PATCH] Concept-like overloading of functions support. When using `enable_if` clauses in templates, we need an NTTP in the mix to let us get good overloading support. The boolean true/false trick of the `enable_if` second parameter actually doesn't work for many situations. --- Meta/overload.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Meta/overload.h diff --git a/Meta/overload.h b/Meta/overload.h new file mode 100644 index 0000000..a9421ea --- /dev/null +++ b/Meta/overload.h @@ -0,0 +1,32 @@ +static_assert( __cplusplus > 201700, "C++17 Required" ); + +#pragma once + +#include + +namespace Alepha::Hydrogen::Meta +{ + inline namespace exports { inline namespace template_overload {} } + + namespace detail::template_overload + { + inline namespace exports {} + + template< std::size_t > + struct holder + { + struct overload_t; + }; + + namespace exports + { + template< std::size_t i > + using overload= typename holder< i >::overload_t *; + } + } + + namespace exports::template_overload + { + using namespace detail::template_overload::exports; + } +}