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

A

Alban.Linard

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
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top