inline Result init( Function const &_function ) { static_assert( fcppt::record::is_object< Result >::value, "Result must be a record::object" ); return fcppt::algorithm::vararg_map( typename Result::all_types{}, []( auto &&... _args ){ return Result{ std::forward< decltype( _args ) >( _args )... }; }, [ &_function ]( auto const _fcppt_element ) { FCPPT_USE( _fcppt_element ); typedef decltype( _fcppt_element ) fcppt_element; return fcppt::record::element_to_label< fcppt_element >{} = _function( fcppt_element{} ); } ); }
typename std::enable_if< !boost::mpl::empty< Sequence >::value, void >::type print( fcppt::io::ostream &_stream ) { fcppt::mpl::for_each< typename boost::mpl::pop_back< Sequence >::type >( [ &_stream ]( auto const _type ) { FCPPT_USE( _type ); fcppt::mpl::detail::print_one< fcppt::tag_type< decltype( _type ) > >( _stream ); _stream << FCPPT_TEXT(','); } ); fcppt::mpl::detail::print_one< typename boost::mpl::back< Sequence >::type >( _stream ); }
std::enable_if_t< !std::is_same< Sequence, ::brigand::list<> >::value, void > print( fcppt::io::ostream &_stream ) { ::brigand::for_each< ::brigand::pop_back< Sequence > >( [ &_stream ]( auto const _type ) { FCPPT_USE( _type ); fcppt::brigand::detail::print_one< ::brigand::type_from< decltype( _type ) > >( _stream ); _stream << FCPPT_TEXT(','); } ); fcppt::brigand::detail::print_one< ::brigand::back< Sequence > >( _stream ); }
inline Array array_init( Function const &_function ) { return Array{ fcppt::container::array::init< typename Array::internal >( [ &_function ]( auto const _fcppt_index ) { FCPPT_USE( _fcppt_index ); return _function( fcppt::brigand::integral_cast< typename Array::enum_type, fcppt::cast::int_to_enum_fun, decltype( _fcppt_index ) >{} ); } ) }; }
inline Dest to_different( Source const &_source ) { static_assert( Dest::dim_wrapper::value == Source::dim_wrapper::value, "dim_wrappers must match" ); return fcppt::math::detail::init< Dest >( [ &_source ]( auto const _index ) { FCPPT_USE( _index ); return fcppt::math::detail::checked_access< _index >( _source ); } ); }
inline T dot( fcppt::math::vector::object< T, N, S1 > const &_left, fcppt::math::vector::object< T, N, S2 > const &_right ) { return fcppt::algorithm::fold( fcppt::math::int_range_count< N >{}, fcppt::literal< T >( 0 ), [ &_left, &_right ]( auto const _index, T const _sum ) { FCPPT_USE( _index ); typedef fcppt::tag_type< decltype( _index ) > index; return _sum + fcppt::math::vector::at< index::value >( _left ) * fcppt::math::vector::at< index::value >( _right ); } ); }
int main() try { fcppt::log::context log_context( fcppt::log::optional_level{ fcppt::log::level::debug }, sge::log::default_level_streams() ); sge::plugin::manager manager( log_context, sge::config::plugin_path(), sge::plugin::optional_cache_ref() ); typedef boost::mpl::vector6< sge::audio::loader, sge::audio::player, sge::font::system, sge::image2d::system, sge::input::system, sge::renderer::core > plugins; fcppt::mpl::for_each< plugins >( [ &manager ]( auto const _tag ) { FCPPT_USE( _tag ); typedef fcppt::tag_type< decltype( _tag ) > type; fcppt::io::cout() << fcppt::type_name_from_info( typeid( type ) ) << FCPPT_TEXT('\n'); for( auto const &plugin : manager.collection< type >() ) { sge::plugin::info const &info( plugin.info() ); fcppt::io::cout() << FCPPT_TEXT("\tname: \"") << info.name() << FCPPT_TEXT("\", description: \"") << info.description() << FCPPT_TEXT("\"\n"); } } ); } catch( fcppt::exception const &_exception ) { fcppt::io::cerr() << _exception.string() << FCPPT_TEXT('\n'); return EXIT_FAILURE; } catch( std::exception const &_exception ) { std::cerr << _exception.what() << '\n'; return EXIT_FAILURE; }
fcppt::container::grid::pos< SizeType, Size > next_position( fcppt::container::grid::pos< SizeType, Size > const _current, fcppt::container::grid::min< SizeType, Size > const _min, fcppt::container::grid::sup< SizeType, Size > const _sup ) { typedef fcppt::container::grid::pos< SizeType, Size > result_type; result_type result{ _current }; ++result.x(); return fcppt::algorithm::fold( fcppt::math::int_range_count< Size - 1u >{}, result, [ &_min, &_sup ]( auto const _index, result_type _result ) { FCPPT_USE( _index ); typedef fcppt::tag_type< decltype( _index ) > index; if( fcppt::math::vector::at< index::value >( _result ) == fcppt::math::vector::at< index::value >( _sup.get() ) ) { fcppt::math::vector::at< index::value >( _result ) = fcppt::math::vector::at< index::value >( _min.get() ); ++ fcppt::math::vector::at< index::value + 1u >( _result ); } return _result; } ); }
T infinity_norm( fcppt::math::matrix::object< T, R, C, S > const &_matrix ) { return fcppt::algorithm::fold( fcppt::math::int_range_count< R >{}, std::numeric_limits< T >::min(), [ &_matrix ]( auto const _row, T const _maximum_row ) { FCPPT_USE( _row ); typedef fcppt::tag_type< decltype( _row ) > row; return std::max( _maximum_row, fcppt::algorithm::fold( fcppt::math::int_range_count< C >{}, fcppt::literal< T >( 0 ), [ &_matrix ]( auto const _column, T const _current_row_sum ) { FCPPT_USE( _column ); typedef fcppt::tag_type< decltype( _column ) > column; return _current_row_sum + std::abs( fcppt::math::matrix::at_c( _matrix, fcppt::math::matrix::index< row::value, column::value >{} ) ); } ) ); } ); }
fcppt::math::vector::static_< T, N + 1u > hypersphere_to_cartesian( fcppt::math::vector::object< T, N, S > const &_angles ) { typedef fcppt::math::vector::static_< T, N + 1u > result_type; typedef typename result_type::value_type value_type; return fcppt::math::vector::init< result_type >( [ &_angles ]( auto const _index ) { FCPPT_USE( _index ); value_type const sins( fcppt::algorithm::fold( fcppt::math::int_range_count< _index() >{}, fcppt::literal< value_type >( 1 ), [ &_angles ]( auto const _inner_index, value_type const _prod ) { FCPPT_USE( _inner_index ); typedef fcppt::tag_type< decltype( _inner_index ) > inner_index; return _prod * std::sin( fcppt::math::at_c< inner_index::value >( _angles ) ); } ) ); result_type const cos_angles( fcppt::math::vector::construct( fcppt::math::vector::init< fcppt::math::vector::static_< T, N > >( [ &_angles ]( auto const _inner_index ) { FCPPT_USE( _inner_index ); return std::cos( fcppt::math::at_c< _inner_index() >( _angles ) ); } ), fcppt::literal< value_type >( 1 ) ) ); return sins * fcppt::math::at_c< _index() >( cos_angles ); } ); }
inline decltype( auto ) runtime_enum( Enum const _enum, Function const &_function ) { static_assert( std::is_enum< Enum >::value, "runtime_enum can only be used on enumeration types" ); typedef typename fcppt::enum_size_type< Enum >::type int_type; return fcppt::mpl::runtime_index< fcppt::enum_size< Enum > >( fcppt::cast::enum_to_int< int_type >( _enum ), [ &_function ]( auto const _fcppt_index ) -> decltype( auto ) { FCPPT_USE( _fcppt_index ); return _function( fcppt::mpl::integral_cast< Enum, fcppt::cast::static_cast_fun, decltype( _fcppt_index ) >{} ); }, &fcppt::absurd< decltype( _function( fcppt::enum_max_value< Enum >{} ) ) > ); }
std::basic_ostream< Ch, Traits > & operator<<( std::basic_ostream< Ch, Traits > &_stream, fcppt::record::object< Types > const &_record ) { _stream << _stream.widen( '{' ); fcppt::algorithm::loop( Types{}, [ &_stream, &_record ]( auto const _element ) { FCPPT_USE( _element ); typedef fcppt::record::element_to_label< fcppt::tag_type< decltype( _element ) > > label; _stream << fcppt::record::label_name< label >() << fcppt::io::widen_string( " = " ) << fcppt::record::get< label >( _record ) << fcppt::io::widen_string( ", " ); } ); return _stream << _stream.widen( '}' ); }
long > list_type; CHECK( fcppt::brigand::invoke_on< list_type >( 1u, []( auto const _type ) -> bool { FCPPT_USE( _type ); return std::is_same< fcppt::tag_type< decltype( _type ) >, long >::value; }, fcppt::const_( false )
}; fcppt::algorithm::loop( brigand::range< int, 0, 5 >{}, [ &value ]( auto const _index ) { FCPPT_USE( _index ); typedef fcppt::tag_type< decltype( _index ) > index; static_assert( index::value < 5, ""
fcppt::record::disjoint_product< fcppt::type_traits::remove_cv_ref_t< Record1 >, fcppt::type_traits::remove_cv_ref_t< Record2 > > multiply_disjoint( Record1 &&_record1, Record2 &&_record2 ) { typedef fcppt::record::disjoint_product< fcppt::type_traits::remove_cv_ref_t< Record1 >, fcppt::type_traits::remove_cv_ref_t< Record2 > > result_type; return fcppt::record::init< result_type >( [ &_record1, &_record2 ]( auto const _fcppt_multiply_disjoint_element ) { FCPPT_USE( _fcppt_multiply_disjoint_element ); return fcppt::record::detail::get_either< fcppt::record::element_to_label< std::remove_const_t< decltype( _fcppt_multiply_disjoint_element ) > >, Record1, Record2 >:: template get< typename std::is_lvalue_reference< Record1 >::type, typename std::is_lvalue_reference< Record2 >::type >( _record1, _record2 ); } ); }
typename sge::noise::perlin::object< Float, N, Interpolator >::value_type sge::noise::perlin::object< Float, N, Interpolator >::sample( vector_type const _v ) const { return fcppt::container::grid::interpolate( gradients_, fcppt::math::vector::init< vector_type >( [ &_v, this ]( auto const _index ) { FCPPT_USE( _index ); typedef decltype( _index ) index; value_type const current_dimension{ fcppt::cast::int_to_float< value_type >( fcppt::math::dim::at< index::value >( gradients_.size() ) ) }; value_type const temp{ FCPPT_ASSERT_OPTIONAL_ERROR( fcppt::math::mod( fcppt::math::vector::at< index::value >( _v ), current_dimension ) ) }; return FCPPT_ASSERT_OPTIONAL_ERROR( fcppt::math::mod( temp + current_dimension, current_dimension ) ); } ), Interpolator() ); }
inline fcppt::math::matrix::detail::static_storage< Type, fcppt::cast::size< fcppt::math::size_type >( R ), C > init_storage( std::array< fcppt::math::matrix::row_type< Type, C >, R > const &_value ) { typedef fcppt::math::matrix::detail::static_storage< Type, fcppt::cast::size< fcppt::math::size_type >( R ), C > result_type; return result_type{ fcppt::container::array::init< typename result_type::array_type >( [ &_value ]( auto const _index ) { FCPPT_USE( _index ); typedef fcppt::math::matrix::detail::index_absolute< C, fcppt::cast::size< fcppt::math::size_type >( _index() ) > index; return fcppt::math::detail::checked_access< index::column() >( std::get< index::row() >( _value ) ); } ) }; }
inline bool contains( fcppt::math::box::object< T, N > const &_outer, fcppt::math::box::object< T, N > const &_inner ) { return fcppt::algorithm::all_of( fcppt::math::int_range_count< N >{}, [ &_outer, &_inner ]( auto const _index ) { FCPPT_USE( _index ); typedef fcppt::tag_type< decltype( _index ) > index; return fcppt::math::at_c< index::value >( _inner.pos() ) >= fcppt::math::at_c< index::value >( _outer.pos() ) && fcppt::math::at_c< index::value >( _inner.max() ) <= fcppt::math::at_c< index::value >( _outer.max() ); } ); }
inline fcppt::math::matrix::static_storage< Type, fcppt::cast::size< fcppt::math::size_type >( R ), fcppt::cast::size< fcppt::math::size_type >( C ) > init_storage( std::array< std::array< Type, C >, R > const &_value ) { return fcppt::algorithm::array_init< fcppt::math::matrix::static_storage< Type, fcppt::cast::size< fcppt::math::size_type >( R ), fcppt::cast::size< fcppt::math::size_type >( C ) > >( [ &_value ]( auto const _index ) { FCPPT_USE( _index ); typedef fcppt::math::matrix::detail::index_absolute< fcppt::cast::size< fcppt::math::size_type >( C ), fcppt::cast::size< fcppt::math::size_type >( _index() ) > index; return std::get< index::column >( std::get< index::row >( _value ) ); } ); }
fcppt::math::matrix::static_< T, N, N > adjugate( fcppt::math::matrix::object< T, N, N, S > const &_matrix ) { typedef fcppt::math::matrix::static_< T, N, N > result_type; return fcppt::math::matrix::init< result_type >( [ &_matrix ]( auto const _index ) { FCPPT_USE( _index ); T const coeff{ ( _index.row + _index.column ) % fcppt::literal< fcppt::math::size_type >( 2 ) == fcppt::literal< fcppt::math::size_type >( 0 ) ? fcppt::literal< T >( 1 ) : fcppt::literal< T >( -1 ) }; // Note: We transpose here because we want the adjugate, not the cofactor // matrix return coeff * fcppt::math::matrix::determinant( fcppt::math::matrix::delete_row_and_column_static( _matrix, fcppt::math::matrix::index< _index.column, _index.row >{} ) ); } ); }