Global Function Error in Partial Specification?

N

Nephi Immortal

I tried to write partial specification on the global function, but the C++ Compiler generates an error. Look at the code and error message below.

1>d:\omega projects\console application\user types\main.cpp(290): error C2182: 'Test' : illegal use of type 'void'
1>d:\omega projects\console application\user types\main.cpp(290): error C2998: 'int Test' : cannot be a template definition
1>d:\omega projects\console application\user types\main.cpp(297): error C2064: term does not evaluate to a function taking 1 arguments

enum class eTypes
{
eA,
eB,
ec
};

template< eTypes eType, typename Integer_Type >
class X
{
private:
public:
template< eTypes eInnerType, typename InnerInteger_Type, InnerInteger_Type Segment >
class Y
{
private:
X< eInnerType, InnerInteger_Type >& reference;

Y( X< eInnerType, InnerInteger_Type >& reference ) : reference( reference )
{
}

~Y()
{
}

Y( const Y< eInnerType, InnerInteger_Type, Segment >& right ) : reference( right.reference )
{
}

Y< eInnerType, InnerInteger_Type, Segment >& operator=( const Y< eInnerType, InnerInteger_Type, Segment >& right )
{
reference.value = right.reference.value;
return *this;
}

Y< eInnerType, InnerInteger_Type, Segment >& operator=( Integer_Type value )
{
reference.value = value;
return *this;
}
};


Integer_Type value;

public:
X( Integer_Type value ) : value( value )
{
}

~X()
{
}

X( const X< eType, Integer_Type >& right ) : value( right.value )
{
}

X& operator=( const X< eType, Integer_Type >& right )
{
value = right.value;
return *this;
}

Y< eType, Integer_Type, 1 > _1() { return Y< eType, Integer_Type, 1 >( *this ); }

};

template< eTypes eInnerType, typename InnerInteger_Type, InnerInteger_Type Segment >
void Test(
const X< eInnerType, InnerInteger_Type >::Y< eInnerType, InnerInteger_Type, Segment >& ref
)
{
}

int main()
{

X< eTypes::eA, int > a = 1;

Test( a._1() );

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top