N
Nephi Immortal
How can I fix partial explicit specification on Go() function before I can declare full explicit specification on struct Outer?
// Outer.h
enum eTypes
{
eA,
eB
};
template< eTypes eType, typename Type >
struct Outer
{
template< eTypes eType, typename Enable >
struct Inner;
template< typename Enable >
struct Inner< eA, Enable >
{
Inner();
~Inner();
Type A();
Type B();
};
template< typename Enable >
struct Inner< eB, Enable >
{
Inner();
~Inner();
Type A();
Type B();
Type C();
Type D();
};
Outer();
~Outer();
Inner< eType, void >
Go();
};
// Outer.cpp
template<>
template<>
Outer< eA, long >::Inner< eA, void >::Inner()
{
}
template<>
template<>
Outer< eA, long >::Inner< eA, void >::~Inner()
{
}
template<>
template<>
long
Outer< eA, long >::Inner< eA, void >::A()
{
return 1;
}
template<>
template<>
long
Outer< eA, long >::Inner< eA, void >::B()
{
return 2;
}
template<>
template<>
Outer< eB, long long >::Inner< eB, void >::Inner()
{
}
template<>
template<>
Outer< eB, long long >::Inner< eB, void >::~Inner()
{
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >::A()
{
return 1;
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >::B()
{
return 2;
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >::C()
{
return 3;
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >:()
{
return 4;
}
template< eTypes eType, typename Type >
Outer< eType, Type >::Outer()
{
}
template< eTypes eType, typename Type >
Outer< eType, Type >::~Outer()
{
}
template< eTypes eType, typename Type >
Outer< eType, Type >::Inner< eType, void >
Outer< eType, Type >::Go()
{
return Inner< eType, void >();
}
template
struct Outer< eA, long >;
template
struct Outer< eB, long long >;
// main.cpp
#include “Outer.h”
int main()
{
long data = 0;
Outer< eA, long > a;
Outer< eB, long long > b;
data = a.Go().A();
data = b.Go().C();
return 0;
}
// Outer.h
enum eTypes
{
eA,
eB
};
template< eTypes eType, typename Type >
struct Outer
{
template< eTypes eType, typename Enable >
struct Inner;
template< typename Enable >
struct Inner< eA, Enable >
{
Inner();
~Inner();
Type A();
Type B();
};
template< typename Enable >
struct Inner< eB, Enable >
{
Inner();
~Inner();
Type A();
Type B();
Type C();
Type D();
};
Outer();
~Outer();
Inner< eType, void >
Go();
};
// Outer.cpp
template<>
template<>
Outer< eA, long >::Inner< eA, void >::Inner()
{
}
template<>
template<>
Outer< eA, long >::Inner< eA, void >::~Inner()
{
}
template<>
template<>
long
Outer< eA, long >::Inner< eA, void >::A()
{
return 1;
}
template<>
template<>
long
Outer< eA, long >::Inner< eA, void >::B()
{
return 2;
}
template<>
template<>
Outer< eB, long long >::Inner< eB, void >::Inner()
{
}
template<>
template<>
Outer< eB, long long >::Inner< eB, void >::~Inner()
{
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >::A()
{
return 1;
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >::B()
{
return 2;
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >::C()
{
return 3;
}
template<>
template<>
long long
Outer< eB, long long >::Inner< eB, void >:()
{
return 4;
}
template< eTypes eType, typename Type >
Outer< eType, Type >::Outer()
{
}
template< eTypes eType, typename Type >
Outer< eType, Type >::~Outer()
{
}
template< eTypes eType, typename Type >
Outer< eType, Type >::Inner< eType, void >
Outer< eType, Type >::Go()
{
return Inner< eType, void >();
}
template
struct Outer< eA, long >;
template
struct Outer< eB, long long >;
// main.cpp
#include “Outer.h”
int main()
{
long data = 0;
Outer< eA, long > a;
Outer< eB, long long > b;
data = a.Go().A();
data = b.Go().C();
return 0;
}