Global Function Error in Partial Specification?

Discussion in 'C++' started by Nephi Immortal, Jan 23, 2013.

  1. 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;
    }
    Nephi Immortal, Jan 23, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Billy
    Replies:
    2
    Views:
    487
    Billy
    Feb 1, 2006
  2. Thomas Heller
    Replies:
    13
    Views:
    841
    Michele Simionato
    Feb 8, 2007
  3. J. Clifford Dyer

    Re: Partial 1.0 - Partial classes for Python

    J. Clifford Dyer, Feb 8, 2007, in forum: Python
    Replies:
    0
    Views:
    508
    J. Clifford Dyer
    Feb 8, 2007
  4. Marek Vondrak
    Replies:
    9
    Views:
    321
    Marek Vondrak
    May 15, 2006
  5. Stefan Ram
    Replies:
    17
    Views:
    452
    James Kanze
    Apr 28, 2009
Loading...

Share This Page