0

I am having trouble turning this into a boost::bimap. It won't compile:

I change:

using MapStudentItemDesc = std::map<UINT, CString>;

to

using MapStudentItemDesc = boost::bimap<UINT, CString>;

And then I declared the map like this:

MapStudentItemDesc mapStudentItemDescBefore;

And I fill it, for example:

rMapStudentItems.insert({IDS_CMB_METHOD_BIBLE_READING, SMMETHOD3(eLanguage, IDS_CMB_METHOD_BIBLE_READING)});

I wanted to be able to easily lookup a value on the right, and thus obtain the associated key on the left.

I get compile errors liek this:

D:\My Libraries\Boost\boost_1_71_0\boost\bimap\detail\bimap_core.hpp(408,1): error C4996: 'std::allocator<void>::rebind<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const unsigned int,boost::bimaps::relation::member_at::left>,boost::bimaps::tags::tagged<const ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>,boost::bimaps::relation::member_at::right>,boost::bimaps::detail::manage_additional_parameters<AP1,AP2,AP3>::case_NNN::additional_info,true>>': warning STL4010: Various members of std::allocator are deprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
5>        with
5>        [
5>            AP1=boost::mpl::na,
5>            AP2=boost::mpl::na,
5>            AP3=boost::mpl::na
5>        ]
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\xmemory(852,1): message : see declaration of 'std::allocator<void>::rebind'
5>D:\My Libraries\Boost\boost_1_71_0\boost\bimap\bimap.hpp(134): message : see reference to class template instantiation 'boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>' being compiled
5>        with
5>        [
5>            KeyTypeA=UINT,
5>            KeyTypeB=CString,
5>            AP1=boost::mpl::na,
5>            AP2=boost::mpl::na,
5>            AP3=boost::mpl::na
5>        ]
5>D:\My Programs\2019\MeetSchedAssist\Meeting Schedule Assistant\ChristianLifeMinistryEditorDlg.cpp(7300): message : see reference to class template instantiation 'boost::bimaps::bimap<UINT,CString,boost::mpl::na,boost::mpl::na,boost::mpl::na>' being compiled
5>D:\My Libraries\Boost\boost_1_71_0\boost\bimap\detail\bimap_core.hpp(407,9): error C4996: 'std::allocator<void>::rebind<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const unsigned int,boost::bimaps::relation::member_at::left>,boost::bimaps::tags::tagged<const ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>,boost::bimaps::relation::member_at::right>,boost::bimaps::detail::manage_additional_parameters<AP1,AP2,AP3>::case_NNN::additional_info,true>>::other': warning STL4010: Various members of std::allocator are deprecated in C++17. Use std::allocator_traits instead of accessing these members directly. You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
5>        with
5>        [
5>            AP1=boost::mpl::na,
5>            AP2=boost::mpl::na,
5>            AP3=boost::mpl::na
5>        ]
5>ChristianLifeMinistryEditorSettingsDlg.cpp
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • Did you read the error? It's warning about deprecated stuff in C++17 that Boost is still using in the version you have. It even tells you how to fix it. – JohnFilleau Dec 21 '20 at 21:43
  • @JohnFilleau Yes, I read it! And I don't understand it. – Andrew Truckle Dec 21 '20 at 21:44
  • @JohnFilleau It implies I can create constant to stop the warnings. But it is not just a warning. It causes the build to fail. – Andrew Truckle Dec 21 '20 at 21:47
  • I see this: https://stackoverflow.com/questions/62226513/boost-bimap-fails-to-compile-with-gcc-10-c20-looking-for-temporary-fix – Andrew Truckle Dec 21 '20 at 21:50
  • Some warnings can be treated as errors depending on your compile options. This is the case here. It's for when the compiler wants to make sure you REALLLLLY understand the risk. – JohnFilleau Dec 21 '20 at 21:51
  • Deprecated means it's an old feature that's going to be removed in future versions. C++14 had a feature, C++17 set it to deprecated so everyone with C++ code who upgraded would have time to switch to the new functions, and C++20 probably removes that feature. You can set your C++ version to 14 if you like. That will also probably fix the error. – JohnFilleau Dec 21 '20 at 21:52
  • This works: `typedef boost::bimap> BiMapStudentItemDesc;` – Andrew Truckle Dec 21 '20 at 21:53
  • 1
    Elevating a warning to an error is common, and it's what a good compiler should do. If this was your code that was giving the warning/error, it would be easy enough to upgrade to the new C++17 feature. But if you're stuck using this Boost library, and there's not a newer one, you have to tell the compiler "Yeah yeah I know, but this is what I'm stuck with." – JohnFilleau Dec 21 '20 at 21:54
  • Hey that looks like a good workaround. You should write up an answer to this question and select it as solved. It will help someone else in the future. – JohnFilleau Dec 21 '20 at 21:54
  • 2
    @JohnFilleau Seems like they fixed it in Boost 1.74.0. Latest is 1.75.0. – Andrew Truckle Dec 21 '20 at 22:10

0 Answers0