Board index » cppbuilder » boost::ref_list_of<> and BCB 6

boost::ref_list_of<> and BCB 6


2005-09-29 04:23:26 AM
cppbuilder85
I'm trying to use boost::ref_list_of (in boost 1.33.0) but BCB 6 give me
errors.
//----- code ------
enum Enum { one, two, three, four, five };
void PrintVector( const std::vector<Enum>& vec )
{
// print the vec
}
void AssignTest()
{
Enum a = one, b = two, c = three;
PrintVector( boost::assign::ref_list_of<3>(a)(b)(c) ); // <-- error
}
//----- end code ------
on the line marked "<--error" I get:
[C++ Error] list_of.hpp(129): E2299 Cannot generate template specialization
from 'converter<static_generic_list<Enum,3>>::convert<Container>(const
Container *,default_type_tag) const'
[C++ Error] list_of.hpp(129): E2285 Could not find a match for
'converter<static_generic_list<Enum,3>>::convert<Container>(const
std::vector<Enum,std::allocator<Enum>>& *,default_type_tag)'
I also tried:
//----- code ------
enum Enum { one, two, three, four, five };
void AssignTest()
{
Enum a = one, b = two, c = three;
std::vector<Enum>vec( boost::assign::ref_list_of<3>(a)(b)(c) );
}
//----- end code ------
and I get (on the ref_list_of line):
[C++ Error] AssignB.cpp(28): E2015 Ambiguity between
'std::vector<Enum,std::allocator<Enum>>::vector(const std::allocator<Enum>
&)' and 'std::vector<Enum,std::allocator<Enum>>::vector(unsigned int)'
Is there a known workaround on this?
Am I doing something wrong?
Thanks.
--
Please remove "sam_" from email address.
 
 

Re:boost::ref_list_of<> and BCB 6

"Sam" < XXXX@XXXXX.COM >wrote in message
Quote
I'm trying to use boost::ref_list_of (in boost 1.33.0) but BCB 6 give me
errors.

//----- code ------
enum Enum { one, two, three, four, five };

void PrintVector( const std::vector<Enum>& vec )
{
// print the vec
}

void AssignTest()
{
Enum a = one, b = two, c = three;

PrintVector( boost::assign::ref_list_of<3>(a)(b)(c) ); // <-- error
}
//----- end code ------

on the line marked "<--error" I get:
[ ... ]
Quote
Is there a known workaround on this?
Am I doing something wrong?
the main problem is: there is no std::vector constructor
that accepts boost::assign::ref_list_of ...
the simpliest workaround I can imagine is to add a conversion
template function that splits one container argument in two iterators
template<typename ResT,typename ArgT>
ResT convertContainer( ArgT const& arg )
{
return ResT( arg.begin(), arg.end() );
}
and than you can use
PrintVector(
convertContainer<std::vector<Enum>>(
boost::assign::ref_list_of<3>(a)(b)(c)
)
);
Cheers,
Serge