1
가변 매개 변수 팩에 대해 다음과 같은 캡슐화 코드가 있습니다.C++ 템플릿 템플릿 인스턴스화
template <typename... Args>
struct pack
{
};
template <template <typename... Args> class ENCAP, typename... Args>
struct encapsulate_arguments
{
typedef pack<ENCAP<Args>...> type;
};
template <template <typename... Args> class ENCAP, typename... Args>
struct encapsulate_arguments<ENCAP, pack<Args...>>
{
typedef pack<ENCAP<Args>...> type;
};
template <typename L>
struct Master
{
template <typename T>
struct Slave
{
typedef T type;
};
};
이 같은 가변 팩을 캡슐화 잘 작동 :
typedef encapsulate_arguments<Master<float>::Slave, double, int>::type foo;
또는
typedef encapsulate_arguments<Master<float>::Slave, pack<double, int>>::type foo;
또는 다른 온도에 의존하지
typedef encapsulate_arguments<std::vector, pack<double, int>>::type foo;
후반 매개 변수 - 다음의 결과는 정의되는 :
pack<Master<float>::Slave<double>, Master<float>::Slave<int>>
또는
pack<std::vector<double>, std::vector<int>>
문제는 내가 따라 캡슐화 템플릿 매개 변수 ENCAP 유형을 만들고 싶어 나는 그것을 컴파일 얻을 수 없다는 것입니다 :
template <typename L>
struct Other
{
// ARGGH!!!
// typedef encapsulate_arguments<Master<L>::Slave, pack<double, int>>::type EmbeddedType;
};
이것도 가능하고 어떻게이 작업을 할 수 있습니까?
실제로 내가 그 트릭이었다이다! 많은 감사합니다. – difftator