Template method implicit instanciation : compiles with Intel ICPC11,not with G++4.x

Discussion in 'C++' started by Alban.Linard@gmail.com, Dec 1, 2008.

  1. Guest

    Hi,
    i cannot explain why g++ complains about the code below:

    #include <cstdlib>

    namespace a
    {
    struct tags
    {
    enum value_type { A0, A1 };
    };

    template < tags::value_type Tag >
    struct element;

    template <>
    struct element< tags::A0 >
    {};

    template <>
    struct element< tags::A1 >
    {};
    }

    namespace b
    {
    struct tags
    {
    enum value_type { B0, B1 };
    };

    template < tags::value_type Tag >
    struct element;

    template <>
    struct element< tags::B0 >
    {};

    template <>
    struct element< tags::B1 >
    {};
    }

    namespace c
    {

    template < typename tags, template < typename tags::value_type >
    class Element >
    struct all
    {
    template < typename tags::value_type Tag >
    all(Element< Tag >)
    {}
    };

    }

    typedef c::all< a::tags, a::element > a_type;
    typedef c::all< b::tags, b::element > b_type;
    typedef a::element< a::tags::A0 > a0_type;
    typedef b::element< b::tags::B0 > b0_type;

    int main()
    {
    a0_type a0;
    b0_type b0;
    b_type b_instance(b0);
    a_type a_instance(a0);
    return EXIT_SUCCESS;
    }

    Intel ICPC compiles it and it works well, but g++ tells:
    error: no matching function for call to 'c::all<a::tags,
    a::element>::all(a0_type&)'
    note: candidates are: c::all<a::tags, a::element>::all(const
    c::all<a::tags, a::element>&)

    Can someone explain me this behavior ?
    Thanks,
    Alban Linard
     
    , Dec 1, 2008
    #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. ik
    Replies:
    2
    Views:
    356
    Janusz Szpilewski
    Sep 2, 2004
  2. ik
    Replies:
    1
    Views:
    346
    Rob Williscroft
    Sep 2, 2004
  3. Uwe Mayer
    Replies:
    2
    Views:
    2,557
    James Kanze
    Aug 3, 2007
  4. whatnext
    Replies:
    9
    Views:
    443
  5. Kazik�
    Replies:
    4
    Views:
    1,395
    Jonathan Lee
    Jul 6, 2009
Loading...

Share This Page