diff --git a/include/utempl/loopholes/counter.hpp b/include/utempl/loopholes/counter.hpp index dd6a7be..eab2e0e 100644 --- a/include/utempl/loopholes/counter.hpp +++ b/include/utempl/loopholes/counter.hpp @@ -1,22 +1,21 @@ #pragma once #include #include +#include namespace utempl::loopholes { namespace impl { -template +template struct TagWithValue {}; -template {}>{}> -constexpr auto Counter(...) { - return I; -}; - -template -consteval auto Counter(std::size_t arg) requires Injected{}, Ts...> { - return Counter(arg); +template +consteval auto Counter() -> std::size_t { + if constexpr(requires{Magic(Getter{}>{});}) { + return Counter(); + }; + return (std::ignore = Injector{}, 0>{}, I); }; } // namespace impl; @@ -24,10 +23,7 @@ consteval auto Counter(std::size_t arg) requires Injected{} template < typename Tag, typename... Ts, - std::size_t R = impl::Counter<0, Tag, Ts...>(std::size_t{}) -#if defined __clang__ - - 1 -#endif + std::size_t R = impl::Counter() > consteval auto Counter(auto...) -> std::size_t { return R;