1
0
forked from Alepha/Alepha

Well this whole () base TMP experiment kinda works.

It's a lot of heavy lifting.  I'm not sure it actually
adds any useful value yet, but I'll continue to play
with it.  It is nice that we can *sometimes* use
loops.  Sometimes we can't though.  And we have
to make some blind-corner evaluations that throw
dummy failures to keep the compiler from complaining
about missing cases -- despite the fact that they;ll
never be reached at compiletime.  (Runtime evaluation
could be different, of course.)

I think, perhaps, a universal representation of a
dereferenced iterator might solve some of this, but
I also don't want to sink too much effort into this,
despite how much fun I'm having.
This commit is contained in:
2021-10-26 01:53:47 -04:00
parent e3d7bbe616
commit cf3f77ba6e
8 changed files with 221 additions and 80 deletions

View File

@ -14,24 +14,38 @@ namespace Alepha::Hydrogen::Meta
{
inline namespace exports
{
template< template< typename, typename > class Function, typename First >
struct bind1st
{
using type= bind1st;
template< typename Arg >
struct call : Function< First, Arg >::type {};
};
template< typename MetaFunction, typename Arg >
constexpr auto bind1st( MetaFunction func, Arg arg );
}
template< template< typename, typename > class Function, typename Second >
struct bind2nd
{
using type= bind2nd;
template< typename Arg >
struct call : Function< Arg, Second >::type {};
};
template< typename MetaFunction, typename Arg > struct binder1st;
template< typename Function, typename ... Args >
struct call : Function::template call< Args... > {};
template< typename MetaFunction, typename Arg1, typename Arg2 >
constexpr decltype( auto )
invoke_call( MetaFunction func, Meta::type_value< Arg1 > arg1, Meta::type_value< Arg2 > arg2 )
{
return func( arg1, arg2 );
}
template< typename MetaFunction, typename Arg >
struct binder1st< MetaFunction, Meta::type_value< Arg > >
{
MetaFunction func;
Meta::type_value< Arg > arg;
template< typename Second >
constexpr decltype( auto )
operator () ( const Second &second )
{
return invoke_call( func, arg, second );
}
};
template< typename MetaFunction, typename Arg >
constexpr auto
exports::bind1st( MetaFunction func, Arg arg )
{
return binder1st< MetaFunction, Arg >{ func, arg };
}
}