I have this problem of conversion with this code using c++11 standard:
#include<unordered_set>
struct B
{
int x, y;
};
class A
{
struct hash
{
std::size_t operator()( int* const a ) const
{
return std::hash<int>()( *a );
}
};
struct equal_to
{
std::size_t operator()( int* const a, int* const b ) const
{
return std::equal_to<int>()( *a, *b );
}
};
private:
std::unordered_set< int*, hash, equal_to > set;
public:
void push( const B& b )
{
set.insert( &b.x );
}
};
Anyone know why is that? I can I solve the problem removing the "const" modifier in the argument of "push". But I don't want it because argument "b" isn't modified.
Edit.: My simplification of code has produced a unreferenced adress. I've make a struct B remove it.