Class nested inside a template class as template function argument type

Discussion in 'C Programming' started by claudiu, Apr 1, 2011.

  1. claudiu

    claudiu Guest

    Hi,

    I run into a bit of trouble trying to compile the code below.

    template<typename T>
    struct Out
    {
    struct In{};
    };

    template<typename T>
    void use(const typename Out<T>::In& r){}

    void test()
    {
    use(Out<int>::In());
    }

    Using Comeau compiler I get the error:

    line 13: error: no instance of function template "use" matches the
    argument list
    The argument types that you used are: (Out<int>::In)
    use(Out<int>::In());
    ^

    It looks like the template function use cannot deduce the argument
    type but I can't understand why. Maybe someone out there can shed some
    light on this?

    Many thanks,
    Claudiu
     
    claudiu, Apr 1, 2011
    #1
    1. Advertising

  2. Re: Class nested inside a template class as template function argumenttype

    On 2011-04-01 13:51, claudiu wrote:
    > Hi,
    >
    > I run into a bit of trouble trying to compile the code below.
    >
    > template<typename T>
    > struct Out
    > {
    > struct In{};
    > };


    Try comp.lang.c++ instead.

    /August

    --
    The competent programmer is fully aware of the limited size of his own
    skull. He therefore approaches his task with full humility, and avoids
    clever tricks like the plague. --Edsger Dijkstra
     
    August Karlstrom, Apr 1, 2011
    #2
    1. Advertising

  3. claudiu

    claudiu Guest

    Re: Class nested inside a template class as template functionargument type

    On Apr 1, 12:59 pm, August Karlstrom <> wrote:
    > On 2011-04-01 13:51, claudiu wrote:
    >
    > > Hi,

    >
    > > I run into a bit of trouble trying to compile the code below.

    >
    > > template<typename T>
    > > struct Out
    > > {
    > >    struct In{};
    > > };

    >
    > Try comp.lang.c++ instead.
    >
    > /August
    >
    > --
    > The competent programmer is fully aware of the limited size of his own
    > skull. He therefore approaches his task with full humility, and avoids
    > clever tricks like the plague. --Edsger Dijkstra


    Ooops, that's what I meant to do. Sorry.
     
    claudiu, Apr 1, 2011
    #3
    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. nw
    Replies:
    0
    Views:
    341
  2. Reckoner
    Replies:
    11
    Views:
    742
    Steven D'Aprano
    Jan 19, 2009
  3. claudiu
    Replies:
    3
    Views:
    514
    claudiu
    Apr 1, 2011
  4. AikidoGuy
    Replies:
    11
    Views:
    596
    Seebs
    Nov 21, 2011
  5. Ryan Dupuis
    Replies:
    8
    Views:
    1,429
    Eric Sosman
    Oct 2, 2013
Loading...

Share This Page