Hi,
I need to adapt a two parameter template to a one parameter template.
I would like to bind the first parameter of a template:
template<class T1, class T2>
struct Two_Parameter_Template {
// Two ctor's
Two_Parameter_Template() { };
template<class Param>
Two_Parameter_Template(Param) { /* ... */ }
};
by using antoher (non intrusive) template mechanism:
//bind the first parameter of a template "bound", this template should work as
//an adapter reducing the number of parameters required
template<class X, template<class, class> class bound>
struct bind_1st {
template<class T> // this is the resulting one parameter template
struct eval {
eval () {
bound<X, T>();
}
template<class T2>
eval (T2 obj) {
bound<X, T>(obj);
}
};
};
So that I could use this template later, as a paremeter for another template, with one less parameter of it's own (something like bellow):
template <template<class> class One_Parameter_Template>
struct SomeTemplate {
//...
};
// Later in the code
typedef SomeTemplate<bind_1st<Bound_Param_class, Two_Parameter_Template> >::eval ConcreteClass;
The question is - is there a syntax in C++ to support this.
Best Regards,
Marcin