invalid explicit specification?

Discussion in 'C++' started by Nephi Immortal, Feb 7, 2013.

  1. When I try to use global function to call two class’ parameters, I got Compiler error message. I don’t see anything wrong in my code. What is going on?

    main.cpp(1714): error C2770: invalid explicit template argument(s) for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))$RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'

    main.cpp(1698) : see declaration of 'Check'

    enum E
    {
    eA,
    eB
    };


    template< E e, typename T >
    struct A
    {
    template< E e2, typename T2, T2 size >
    struct B
    {
    B()
    {
    }

    ~B()
    {
    }
    };

    A()
    {
    }

    ~A()
    {
    }

    };

    template< E e2, typename T2, T2 size >
    void
    Check(
    A< e2, T2 > ref,
    typename A< e2, T2 >::B< e2, T2, size > ref2
    )
    {
    }


    int main()
    {
    A< eA, int > a;
    A< eA, int >::B< eA, int, 1 > b;

    Check< eA, int, 1 >(
    a,
    b
    );

    return 0;
    }
     
    Nephi Immortal, Feb 7, 2013
    #1
    1. Advertising

  2. Nephi Immortal

    Öö Tiib Guest

    On Thursday, 7 February 2013 05:18:54 UTC+2, Nephi Immortal wrote:
    > When I try to use global function to call two class’ parameters,
    > I got Compiler error message. I don’t see anything wrong in my
    > code. What is going on?
    >
    > main.cpp(1714): error C2770: invalid explicit template argument(s)
    > for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))
    > $RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'
    >
    > main.cpp(1698) : see declaration of 'Check'


    That you should complain to Microsoft. Their error messages are indeed
    close to useless. BTW ... you really have 1650 lines of trash in your
    main.cpp?

    > enum E { eA, eB };
    >
    > template< E e, typename T >
    > struct A
    > {
    > template< E e2, typename T2, T2 size >
    > struct B
    > {
    > B() { }
    > ~B() { }
    > };
    >
    > A() { }
    > ~A() { }
    > };
    >
    > Check(
    > A< e2, T2 > ref,
    > typename A< e2, T2 >::B< e2, T2, size > ref2
    > )
    > {
    > }


    It should be:

    template<E e2, typename T2, T2 sizex>
    void Check( A<e2, T2> ref
    , typename A<e2, T2>::template B<e2, T2, sizex> ref2 )
    { }

    AFAIK 'template' is needed here ^^^^^^^^ to indicate usage of
    nested template. Error comes at call site since compilers are not
    required evaluate/diagnose template syntax much before actual
    attempt to use it.

    > int main()
    > {
    > A<eA, int> a;
    > A<eA, int>::B<eA, int, 1> b;
    > Check<eA, int, 1>( a, b );
    > return 0;
    > }
     
    Öö Tiib, Feb 7, 2013
    #2
    1. Advertising

  3. On Thursday, February 7, 2013 6:17:52 AM UTC-6, Öö Tiib wrote:
    > On Thursday, 7 February 2013 05:18:54 UTC+2, Nephi Immortal wrote:
    >
    > > When I try to use global function to call two class’ parameters,

    >
    > > I got Compiler error message. I don’t see anything wrong in my

    >
    > > code. What is going on?

    >
    > >

    >
    > > main.cpp(1714): error C2770: invalid explicit template argument(s)

    >
    > > for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))

    >
    > > $RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'

    >
    > >

    >
    > > main.cpp(1698) : see declaration of 'Check'

    >
    >
    >
    > That you should complain to Microsoft. Their error messages are indeed
    >
    > close to useless. BTW ... you really have 1650 lines of trash in your
    >
    > main.cpp?


    Please do not say if I have 1650 lines of trash in my main.cpp. I have a lot of functions and/or classes above main() function. I select important lines so that I can post them to the newsgroups. You have no reason to readall 1650 lines!

    >
    >
    >
    > > enum E { eA, eB };

    >
    > >

    >
    > > template< E e, typename T >

    >
    > > struct A

    >
    > > {

    >
    > > template< E e2, typename T2, T2 size >

    >
    > > struct B

    >
    > > {

    >
    > > B() { }

    >
    > > ~B() { }

    >
    > > };

    >
    > >

    >
    > > A() { }

    >
    > > ~A() { }

    >
    > > };

    >
    > >

    >
    > > Check(

    >
    > > A< e2, T2 > ref,

    >
    > > typename A< e2, T2 >::B< e2, T2, size > ref2

    >
    > > )

    >
    > > {

    >
    > > }

    >
    >
    >
    > It should be:
    >
    >
    >
    > template<E e2, typename T2, T2 sizex>
    >
    > void Check( A<e2, T2> ref
    >
    > , typename A<e2, T2>::template B<e2, T2, sizex> ref2 )
    >
    > { }


    I am not sure I understand your comment. I already posted “template< E e2, typename T2, T2 size > void”, but you deleted it before “Check(….)”. Why did you repost my copied line here?

    Do GCC C++ Compiler and Intel C++ Compiler generate no error message with template implementation? It means that Microsoft does not do good job to write C++ Compiler themselves.

    The alternative option is to move B class outside class A. I do not want client to access B class directly. I choose A struct and B struct so that Ican demonstrate template problem.

    >
    >
    >
    > AFAIK 'template' is needed here ^^^^^^^^ to indicate usage of
    >
    > nested template. Error comes at call site since compilers are not
    >
    > required evaluate/diagnose template syntax much before actual
    >
    > attempt to use it.


    Do not make any sense since you deleted one line above.

    >
    >
    >
    > > int main()

    >
    > > {

    >
    > > A<eA, int> a;

    >
    > > A<eA, int>::B<eA, int, 1> b;

    >
    > > Check<eA, int, 1>( a, b );

    >
    > > return 0;

    >
    > > }
     
    Nephi Immortal, Feb 7, 2013
    #3
  4. Nephi Immortal

    Stuart Guest

    On Thursday, 7 February 2013, Nephi Immortal wrote:
    >>> When I try to use global function to call two class’
    >>> parameters, I got Compiler error message. I don’t see
    >>> anything wrong in my code. What is going on?
    >>>
    >>> main.cpp(1714): error C2770: invalid explicit template
    >>> argument(s) for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(
    >>> *(_BAAB@))$RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'
    >>>
    >>> main.cpp(1698) : see declaration of 'Check'
    >>>
    >>> enum E { eA, eB };
    >>>
    >>> template< E e, typename T >
    >>> struct A
    >>> {
    >>> template< E e2, typename T2, T2 size >
    >>> struct B
    >>> {
    >>> B() { }
    >>> ~B() { }
    >>> };
    >>>
    >>> A() { }
    >>> ~A() { }
    >>> };
    >>>
    >>> Check(
    >>> A< e2, T2 > ref,
    >>> typename A< e2, T2 >::B< e2, T2, size > ref2
    >>> )
    >>> {
    >>> }


    On February 7, 2013, Öö Tiib wrote:
    >> It should be:
    >>
    >> template<E e2, typename T2, T2 sizex>
    >> void Check( A<e2, T2> ref
    >> , typename A<e2, T2>::template B<e2, T2, sizex> ref2 )
    >> { }


    On 02/07/13, Nephi Immortal wrote:
    > I am not sure I understand your comment. I already
    > posted “template< E e2, typename T2, T2 size > void”,
    > but you deleted it before “Check(….)”. Why did you
    > repost my copied line here?


    Take a closer look. There is an additional keyword in the line that Öö
    posted. He tried to draw your attention to this additional keyword by
    adding the " ^^^^^^^^ " in the next line along with the word "here".
    IMHO, this should be quite a strong hint.

    On February 7, 2013, Öö Tiib wrote:
    >> AFAIK 'template' is needed here ^^^^^^^^ to indicate usage of


    See?

    Regards,
    Stuart

    PS: You should use a different newsreader which does not add superflous
    blank lines. That makes your posting difficult to read. Also there is a
    netiquette that states that USENET postings should restrict the number
    of characters to 80 per line. This makes posting readable with command
    line clients and should not hurt too much since long lines are generally
    bad to read.
     
    Stuart, Feb 8, 2013
    #4
  5. Nephi Immortal

    Öö Tiib Guest

    On Thursday, 7 February 2013 22:48:43 UTC+2, Nephi Immortal wrote:
    > Please do not say if I have 1650 lines of trash in my main.cpp.


    The program looked like tiny test, I usually do not put such into
    some file with important code. You are correct, it is none my business
    to weight your practices.

    > Do GCC C++ Compiler and Intel C++ Compiler generate no error message
    > with template implementation?


    I don't think that your original code compiles on other compilers.
    I bashed Microsoft for the confusing "_BAAC!"@£%(*(_BAAD@))" vomits.

    > Do not make any sense since you deleted one line above.


    I accidentally deleted it, sorry.
    If that line helps you in any way then put it back.
    What I wrote is anyway true, replacing yours 'Check' with mine works.
     
    Öö Tiib, Feb 8, 2013
    #5
  6. Nephi Immortal

    Rosario1903 Guest

    On Wed, 6 Feb 2013 19:18:54 -0800 (PST), Nephi Immortal
    <> wrote:

    >When I try to use global function to call two class’ parameters, I got Compiler error message. I don’t see anything wrong in my code. What is going on?
    >
    >main.cpp(1714): error C2770: invalid explicit template argument(s) for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))$RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'
    >
    >main.cpp(1698) : see declaration of 'Check'
    >
    >enum E
    >{
    > eA,
    > eB
    >};


    are 'E' start names reserved?
    than here not compile because don't find the definition for A.
    a too much big subset of c++ is too much difficult
     
    Rosario1903, Feb 10, 2013
    #6
    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. J.T. Conklin
    Replies:
    1
    Views:
    445
    David Hilsee
    Aug 11, 2004
  2. Andy
    Replies:
    5
    Views:
    512
    Shezan Baig
    Jan 30, 2005
  3. Patrick.O.Ige
    Replies:
    1
    Views:
    1,972
    Patrick.O.Ige
    Jul 2, 2006
  4. Replies:
    1
    Views:
    583
    Salt_Peter
    Dec 25, 2006
  5. Nephi Immortal

    How to do full explicit specification?

    Nephi Immortal, Jan 16, 2013, in forum: C++
    Replies:
    6
    Views:
    230
    Nephi Immortal
    Jan 16, 2013
Loading...

Share This Page