Мне нужно адаптировать шаблон с двумя параметрами к шаблону с одним параметром.
Я бы хотел связать первый параметр шаблона:
template<class T1, class T2>
struct Two_Parameter_Template {
// Two ctor's
Two_Parameter_Template() { };
template<class Param>
Two_Parameter_Template(Param) { /* ... */ }
};
с использованием механизма шаблонов antoher (не навязчивый):
//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);
}
};
};
Чтобы я мог использовать этот шаблон позже, в качестве параметра для другого шаблона, с одним собственным параметром (что-то вроде ниже):
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;
Вопрос в том, есть ли в C ++ синтаксис для поддержки этого.
С наилучшими пожеланиями,
Marcin