2016-06-23 3 views
2

이것이 가능할 지 모르겠지만 주어진 클래스에서 일부 템플릿 매개 변수를 숨기고 싶습니다. 여기에 내 말은 나는 다음과 같은 코드가 무슨 말 : 지금에 대해 알 필요가없는 바되어C++ 템플릿 매개 변수 숨기기

template<class A, int b> 
class Foo 
{ 
}; 
template<template<class,int> class Foo_specialized, class A, int b> 
class Bar 
{ 
    Foo_specialized<A,b> obj; 
}; 

을하지만, 나에 대해 알 필요가있다. 이 같은 자연적으로 뭔가 완벽 할 것 (다음이 의사 코드는 단지 아이디어를 설명하는 것입니다) :

template<template<int> class Foo_specialized_by_first_parameter, int b> 
class Bar 
{ 
    Foo_specialized_by_first_parameter<b> obj; 
}; 

나는 그 모든 가능하다면 정말 모르겠어요을, 아이디어는 이런 일을하는 것입니다 인스턴스화 할 때 Bar :

Bar<Foo<float>, 5> bar_instance; 

Foo는 1 개의 매개 변수를 허용하지 않기 때문에 물론 작동하지 않습니다. 기본적으로 (Foo<float>)<5>과 같은 것이 필요합니다. 제가 생각할 수있는 가장 가까운 것은 haskell에서 currying입니다. 당신이 할 수

template <template<int> class Foo_specialized_by_first_parameter, int b> 
class Bar 
{ 
    Foo_specialized_by_first_parameter<b> obj; 
}; 

로, 다음

template <int N> 
using Foo_float = Foo<float, N>; 

그리고 :

Bar<Foo_float, 5> bar_instance; 
+1

간단하게 'Bar '이 아닌 이유는 무엇입니까? template