3
다른 std :: map 값을 사용하여 std :: map을 만들고 싶습니다.이지도를 임의의 깊이에 중첩 할 수 있기를 원합니다. 나는이 수정 길이 할 간단 알고 있지만 변수 깊이 중 하나를 구축하는 접근 방법이 확실하지가변 깊이의 중첩 된지도를 만드는 방법
std::map < std::string, std::map < std::string, int> > d1;
// so the next depth would be.
std::map < std::string, std::map < std::string, std::map < std::string, int> > > d2;
: 여기
은 기본 예입니다.template<typename Key, typename Value, unsigned int N>
struct VarMapHelper
{
typedef std::map<Key, typename VarMapHelper<Key, Value, N-1>::type> type;
};
template<typename Key, typename Value>
struct VarMapHelper<Key, Value, 1>
{
typedef std::map<Key, Value> type;
};
template<typename Key, typename Value, unsigned int N>
using VarMap = typename VarMapHelper<Key, Value, N>::type;
이 좋아 사용 : : 우리가 using
전문 기운으로
이러한 클래스를 사용하는 방법에 대한 예를 보여줄 수 있습니까? – Brian