static_assert( __cplusplus > 2020'99 ); #pragma once #include #include #include #include #include #include #include #include #include namespace Alepha::Hydrogen::IOStreams ::detail:: OStreamable_m { inline namespace exports { struct OStreamable {}; } template< typename T > concept OStreamableAggregate= Aggregate< T > // For now, this part seems to have problems, since the `has_capability` function // is either broken... or gcc has a bug which prevents it from functioning // correctly. // // Therefore, we just allow the aggregate case, for the moment. Which is the // most common case, anyhow. //and Capability< T, OStreamable > ; template< OStreamableAggregate Agg > std::ostream & operator << ( std::ostream &os, Agg &ostreamable ) { const auto decomposed= Alepha::Reflection::tuplizeAggregate( ostreamable ); //static_assert( Capability< Agg, exports::OStreamable > ); auto delim= adaptStream( StartDelimitedList{ []( std::ostream &os ) { os << fieldDelimiter; } }, os ); // TODO: Consider the lens system here... but the basic use case seems to be for // aggregates, so we'll go with this simple case for now... template_for( decomposed ) <=[&]( const auto &element ) { os << NextItem << element; }; return os; } } namespace Alepha::Hydrogen::IOStreams::inline exports::inline OStreamable_m { using namespace detail::OStreamable_m::exports; }