Search code examples
boostbimap

Passing a boost::bimap between functions


I'm new to the bimap functionality of the Boost libraries, and I'm having trouble passing a bimap into another function. My bimap looks like this:

typedef boost::bimap< int, int > bimap_type;
bimap_type bm;

I have an add_values() function that adds a set of values to the bimap:

add_values(int a, int b)
{
 bm.insert(bimap_type::value_type(a, b));
}

I then have a function that is meant to set the values of the bimap by getting them from a Singleton Class:

void set_values()
{
 MyClass::instance()->get_values(bm);
}

And, in MyClass, get_values() looks like this:

void get_values(bimap_type myBimap)
{
 myBimap.add_values(3, 5);
}

However, MyClass does not recognise 'bimap_type'. I try putting the typedef in a separate header file and including that in MyClass, but I get the error message:

'class bimap_type' has no member named 'add_values'

How can I successfully pass the bimap to this Singleton Class in order to fill it with values from the Class? Does anyone know?

Thanks a lot.


Solution

  • Er, boost::bimap itself doesn't have an add_values method and it's hard to tell from these code fragments why you're suddenly expecting one to appear.