[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

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

Alban.Linard

12/1/2008 4:22:00 PM

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