#define _CRT_SECURE_NO_DEPRECATE
#define _SCL_SECURE_NO_DEPRECATE
#include <boost/config.hpp>
#include <string>
#include <iostream>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/support/lambda.hpp>
using namespace boost::bimaps;
void test_replace()
{
typedef bimap< int, std::string > bm_type;
bm_type bm;
bm.insert( bm_type::value_type(1,"one") );
{
bm_type::right_iterator it = bm.right.find("one");
bool successful_replace = bm.right.replace_key( it, "1" );
assert( successful_replace );
}
bm.insert( bm_type::value_type(2,"two") );
{
assert( bm.size() == 2 );
bm_type::left_iterator it = bm.left.find(1);
bool successful_replace = bm.left.replace_data( it, "two" );
assert( ! successful_replace );
assert( bm.size() == 2 );
}
}
void test_modify()
{
typedef bimap< int, std::string > bm_type;
bm_type bm;
bm.insert( bm_type::value_type(1,"one") );
{
bm_type::right_iterator it = bm.right.find("one");
bool successful_modify = bm.right.modify_key( it , _key = "1" );
assert( successful_modify );
}
bm.insert( bm_type::value_type(2,"two") );
{
assert( bm.size() == 2 );
bm_type::left_iterator it = bm.left.find(1);
bool successful_modify = bm.left.modify_data( it, _data = "two" );
assert( ! successful_modify );
assert( bm.size() == 1 );
}
}
int main()
{
test_replace();
test_modify();
return 0;
}