codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <boost/utility/enable_if.hpp> #include <boost/mpl/greater.hpp> #include <boost/mpl/comparison.hpp> #include <boost/mpl/size_t.hpp> using namespace boost; template <typename Interp> struct S { static void Process( int x ) { Interp::Call( x ); } static void Process( int x, typename enable_if< mpl::greater< typename Interp::NbrArgs, mpl::size_t<0> >, typename Interp::Arg0 >::type a0 ) { Interp::Call( x, a0 ); } static void Process( int x, typename enable_if< mpl::greater< typename Interp::NbrArgs, mpl::size_t<0> >, typename Interp::Arg0 >::type a0, typename enable_if< mpl::greater< typename Interp::NbrArgs, mpl::size_t<1> >, typename Interp::Arg1 >::type a1 ) { Interp::Call( x, a0, a1 ); } }; struct Linear0 { typedef mpl::size_t<0> NbrArgs; typedef void Arg0; typedef void Arg1; static void Call( int x ) { } }; struct Linear1 { typedef mpl::size_t<1> NbrArgs; typedef double Arg0; typedef void Arg1; static void Call( int x, Arg0 a0 ) { } }; struct Linear2 { typedef mpl::size_t<2> NbrArgs; typedef double Arg0; typedef double Arg1; static void Call( int x, Arg0 a0, Arg1 a1 ) { } }; int main(int) { S<Linear0>::Process( 5 ); S<Linear1>::Process( 5, .5 ); S<Linear2>::Process( 5, .5, .6 ); return 1; }
Private
[
?
]
Run code
Submit