libc++'s unorderd_map bug?

Hi,

Both calng++ and g++ with libc++ fail to compile the attached piece of code,
$ clang++ -std=c++0x -stdlib=libc++ unordered_map.cpp

In file included from ./unordered_map.cpp:1:
/usr/include/c++/v1/string:1031:35: error: no type named ‘char_type’ in
‘Parameter’
typedef typename traits_type::char_type value_type;


(lots of error messages)

However, it can be compiled against libstdc++
$ calng++ -std=c++0x unordered_map.cpp

I'm not sure if the program conforms strictly to the standard or it's a bug in libc++.
Any comment will be appreciated.

Thanks,

Ryuta

#include <string>
#include <map>
#include <unordered_map>

class Parameter
{
public:
explicit Parameter( bool arg );
Parameter();
~Parameter();

unsigned int offset;
bool argument;
};

class PTXKernel
{
typedef std::map<std::string,Parameter> ParameterMap;

public:
PTXKernel( const std::string& name = "" );
PTXKernel( const PTXKernel& k );
~PTXKernel();

ParameterMap parameters;

std::string name;
};

class Module
{
public:
typedef std::unordered_map< std::string, PTXKernel > KernelMap;

private:
KernelMap _kernels;

public:
void insertKernel( const PTXKernel& kernel );
};

///////////////////////////////////////////////////////////////////////////////
/

Parameter::Parameter()
{
offset = 0;
argument = false;
}

Parameter::~Parameter() { }

Parameter::Parameter( bool arg ) : argument(arg)
{
offset = 0;
}

/////////////////////////////

PTXKernel::PTXKernel( const std::string& n ) : name(n)
{
parameters.insert(make_pair(name,Parameter()));
}

PTXKernel::PTXKernel( const PTXKernel& kernel )
{
name = [kernel.name](http://kernel.name);
parameters = kernel.parameters;
}

PTXKernel::~PTXKernel() { }

/////////////////////////////

void Module::insertKernel( const PTXKernel& kernel )
{
_kernels.insert( std::make_pair([kernel.name](http://kernel.name),kernel) );
}

/////////////////////////////

int main()
{
PTXKernel k1( "k1" );
PTXKernel k2( "k2" );

Module m;

m.insertKernel( k1 );
m.insertKernel( k2 );

return 0;
}

Hello,

Both calng++ and g++ with libc++ fail to compile the attached piece of code,
$ clang++ -std=c++0x -stdlib=libc++ unordered_map.cpp

In file included from ./unordered_map.cpp:1:
/usr/include/c++/v1/string:1031:35: error: no type named 'char_type' in
      'Parameter'
    typedef typename traits_type::char_type value_type;
            ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~

(lots of error messages)

Looks like PR10087: <http://llvm.org/bugs/show_bug.cgi?id=10087>

Try the workaround posted there by switching the includes for string and map/unordered_map.
Or revert to an older version of libc++, if this is possible for you. I'm using r131852,
which does not contain this bug.

Jonathan