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

@ -15,6 +15,29 @@ namespace Alepha::Hydrogen::Meta::Container
inline namespace exports
{
template< typename ... Members > struct vector;
template< typename ... Members >
constexpr auto
template_for( vector< Members... > );
}
template< typename ... Members >
struct template_for_binder
{
template< typename Body >
constexpr void
operator <=( Body b )
{
auto wrapper= [&]( auto element ) { b( element ); return nullptr; };
std::nullptr_t loop[]= { wrapper( type_value< Members >{} )... };
}
};
template< typename ... Members >
constexpr auto
exports::template_for( vector< Members... > )
{
return template_for_binder< Members... >{};
}
template< typename Vector >
@ -44,6 +67,22 @@ namespace Alepha::Hydrogen::Meta::Container
{
vector_iterator< List > iter;
};
template< typename MetaFunction, typename Arg1, typename First, typename ... Members >
constexpr decltype( auto )
invoke_call( MetaFunction func, type_value< Arg1 > arg1, dereferenced_iterator< vector< First, Members... > > deref )
{
if( deref.iter.offset == 0 ) return func( arg1, type_value< First >{} );
else return invoke_call( func, arg1, dereferenced_iterator< vector< Members... > >{ deref.iter.offset - 1 } );
}
template< typename MetaFunction, typename Arg1, typename First >
constexpr decltype( auto )
invoke_call( MetaFunction func, type_value< Arg1 > arg1, dereferenced_iterator< vector< First > > deref )
{
if( deref.iter.offset == 0 ) return func( arg1, type_value< First >{} );
else throw "Out of bounds iterator";
}
template< typename First, typename ... Members, typename Value >
constexpr bool