-
June 4th, 2018, 09:13 AM
#1
Compilation issue with the boost::assign:list_of and map_list_of
Hello,
I have added boost::assign:list_of and map_list_of in the following way in my project. The same compiles when I try to do the local testing with the folowing function:
Code:
#include <boost/assign.hpp>
using namespace std;
using boost::assign::list_of;
using boost::assign::map_list_of;
typedef map<string,int> value_type;
typedef map<string,value_type> map_type;
map_type someMap =
boost::assign::list_of<map_type::value_type>
("ex",
boost::assign::map_list_of
("ab", 1)
("xy", 2)
)
;
int main()
{
}
But when I add as part of the Project like
In .h file:
Code:
typedef map<string, int> MediaType2GBR;
typedef map<string, MediaType2GBR> Subcat2MediaType2GBR;
class CPCRF : public CBaseClass
{
public:
static std::map<std::string, PcrfMediaType_Value> m_mMapStringToPcrfMediaType;
};
And in the .cpp file:
Code:
Subcat2MediaType2GBR CPCRF::m_mServiceType2MediaType2GBR =
boost::assign::list_of<MediaType2GBR>
(
"Gold",
boost::assign::map_list_of
("Audio", 10)
("Video", 20)
);
I am getting the compilation error:
/root/SVN_ROOT/../SVN_THIRDPARTY/boost/ECX_Boost_1_63_0_tag1/x86/include/boost/preprocessor/iteration/detail/local.hpp: In member function ‘boost::assign_detail::generic_list<T>& boost::assign_detail::generic_list<T>:perator()(const U&, const U0&) [with U = char [5], U0 = boost::assign_detail::generic_list<std:air<const char*, int> >, T = std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std:air<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > >]’:
/root/SVN_ROOT/../SVN_THIRDPARTY/boost/ECX_Boost_1_63_0_tag1/x86/include/boost/preprocessor/iteration/detail/local.hpp:37: instantiated from ‘boost::assign_detail::generic_list<T> boost::assign::list_of(const U&, const U0&) [with T = std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std:air<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> > >, U = char [5], U0 = boost::assign_detail::generic_list<std:air<const char*, int> >]’
ransrc/CPCRF.cpp:95: instantiated from here
-
June 5th, 2018, 06:55 AM
#2
Re: Compilation issue with the boost::assign:list_of and map_list_of
That error is unreadable. Please use code tags to post such errors.
You are not pasting all the code, so it's hard to follow. The .h contains an m_mMapStringToPcrfMediaType, while the .cpp talks about m_mServiceType2MediaType2GBR .
Can you post the correct pieces of code?
Also, post the entire error you get. I suspect that is not the entire error you are showing.
-
June 5th, 2018, 08:41 AM
#3
Re: Compilation issue with the boost::assign:list_of and map_list_of
Tried to cutpaste the entire error, but codeguru is not allowing me to do so..
Sorry the .h:
Code:
typedef map<string, int> MediaType2GBR;
typedef map<string, MediaType2GBR> Subcat2MediaType2GBR;
class CPCRF : public CBaseClass
{
public:
static Subcat2MediaType2GBR m_mServiceType2MediaType2GBR;
};
And in .cpp is:
Code:
Subcat2MediaType2GBR CPCRF::m_mServiceType2MediaType2GBR =
boost::assign::list_of<MediaType2GBR>
(
"Gold",
boost::assign::map_list_of
("Audio", 10)
("Video", 20)
);
-
June 5th, 2018, 08:54 AM
#4
Re: Compilation issue with the boost::assign:list_of and map_list_of
Instead of boost::assign::list_of<MediaType2GBR>, you should use boost::assign::list_of<map_type::value_type>
-
June 5th, 2018, 09:06 AM
#5
Re: Compilation issue with the boost::assign:list_of and map_list_of
When I try the following:
Subcat2MediaType2GBR CPCRF::m_mServiceType2MediaType2GBR =
boost::assign::list_of<Subcat2MediaType2GBR::MediaType2GBR>
(
"Gold",
boost::assign::map_list_of
("Audio", 10)
("Video", 20)
);
I get the following error:
ransrc/CPCRF.cpp:86: error: ‘MediaType2GBR’ is not a member of ‘Subcat2MediaType2GBR’
-
June 5th, 2018, 09:12 AM
#6
Re: Compilation issue with the boost::assign:list_of and map_list_of
Sorry my mistake.
boost::assign::list_of<Subcat2MediaType2GBR::MediaType2GBR> should be boost::assign::list_of<Subcat2MediaType2GBR::value_type>
-
June 5th, 2018, 09:31 AM
#7
Re: Compilation issue with the boost::assign:list_of and map_list_of
Thanks a lot Marc, now it looks like it worked(compilation is proceeding further..hopefully finally links )
-
June 5th, 2018, 09:35 AM
#8
Re: Compilation issue with the boost::assign:list_of and map_list_of
You're welcome
Feel free to rate the answer.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|