jxbma
asked on
How do I retrieve a value from a boost::bimap by key in VS C++?
Hi:
First time using boost::bimap.
I have constructed the following typedef:
typedef boost::bimap<std::basic_st ring<TCHAR >, int> argvType;
I load values into the bimap:
argvType arguments;
for (int index = 0; index < argc; index++)
{
arguments.insert(argvType: :value_typ e(argv[ind ex], index));
}
How do I retrieve a value from the bimap assuming I'm using the following key:
std::basic_string<TCHAR> fileIn = L"foo";
I want to retrieve the string value in the map associated with the key.
I know there's probably better ways to do this, but I'd like to stick with
the implementation I've started.
I would think I should be able to use a [] operator or a get().
How do this?
Thanks,
JohnB
First time using boost::bimap.
I have constructed the following typedef:
typedef boost::bimap<std::basic_st
I load values into the bimap:
argvType arguments;
for (int index = 0; index < argc; index++)
{
arguments.insert(argvType:
}
How do I retrieve a value from the bimap assuming I'm using the following key:
std::basic_string<TCHAR> fileIn = L"foo";
I want to retrieve the string value in the map associated with the key.
I know there's probably better ways to do this, but I'd like to stick with
the implementation I've started.
I would think I should be able to use a [] operator or a get().
How do this?
Thanks,
JohnB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All I really want to do is to retrieve the "value" at that key if it exists.
Not clear to me yet how to do that.
Not clear to me yet how to do that.
Ooops, sorry, should have been
argvType::right_map::iterator it = argument.right.find(fileIn);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Mmmm...
Still missing something here.
still produces:
Error 141 error C2664: 'int boost::bimaps::container_a daptor::de tail::key_ to_base_id entity<int ,KeyType>: :operator ()(Key &) const' : cannot convert argument 1 from 'const std::basic_string<wchar_t, std::char_ traits<wch ar_t>,std: :allocator <wchar_t>> ' to 'const int &' c:\boost\include\boost\bim ap\contain er_adaptor \associati ve_contain er_adaptor .hpp 194
Error 142 error C2780: 'boost::multi_index::detai l::bidir_n ode_iterat or<boost:: multi_inde x::detail: :ordered_i ndex_node< Super>> boost::multi_index::detail ::ordered_ index<boos t::multi_i ndex::memb er<boost:: bimaps::re lation::de tail::rela tion_stora ge<TA,TB,t rue>,int,p ointer-to- member(0x1 c)>,std::l ess<int>,S uperMeta,b oost::mpl: :vector1<T 0>,boost:: multi_inde x::detail: :ordered_u nique_tag> ::find(con st CompatibleKey &,const CompatibleCompare &) const' : expects 2 arguments - 1 provided c:\boost\include\boost\bim ap\contain er_adaptor \associati ve_contain er_adaptor .hpp 195
Still missing something here.
std::basic_string<TCHAR> fileIn = L"-f";
argvType::right_map::iterator it = arguments.right.find(fileIn);
still produces:
Error 141 error C2664: 'int boost::bimaps::container_a
Error 142 error C2780: 'boost::multi_index::detai
ASKER
I think I'm missing something there.
I get the following compilation error:
Open in new window