Skip to content

Comparison of generic interfaces

headmyshoulder edited this page Jun 9, 2013 · 3 revisions

Boost.Graph

Boost.Graph uses function overloading for the high level interface

template< class T1 , class T2 >
high_level_function( T1 t1 , T2 t2 ) { t1.function( t2); }

Boost.Fusion

Boost.Fusion uses function overloading with one layer between the high level interface and the implementation

template< class T1 >
struct high_level_function_impl
{
    template< class T2 >
    void apply( T1 t1 , T2 t2 ) { t1.function( t2 ); }
};

template< class T1 , class T2 >
void high_level_function( T1 t1 , T2 t2 ) { high_level_function_impl< T1 >::apply( t1 , t2 ); }