k***p 发帖数: 115 | 1 我的compiler是gcc 4.7。 多谢
$g++ testAny.cpp -o testAny
testAny.cpp: In function ‘void AnyTesting3()’:
testAny.cpp:66:54: error: no match for ‘operator=’ in ‘myPropertySet.std:
:map<_Key, _Tp, _Compare, _Alloc>::operator[], boost
::any, std::less >, std::allocator
std::basic_string, boost::any> > >((* & std::basic_string(((
const char*)"BarrType"), (*(const std::allocator*)(& std::allocator<
char>()))))) = (BarrierType)0u’
testAny.cpp:66:54: note: candidates are:
In file included from testAny.cpp:1:0:
/usr/include/boost/any.hpp:69:15: note: template boost::any
& boost::any::operator=(const ValueType&)
testAny.cpp:66:54: error: template argument for ‘template
boost::any& boost::any::operator=(const ValueType&)’ uses local type ‘
AnyTesting3()::BarrierType’
testAny.cpp:66:54: error: trying to instantiate ‘template
> boost::any& boost::any::operator=(const ValueType&)’
In file included from testAny.cpp:1:0:
/usr/include/boost/any.hpp:75:15: note: boost::any& boost::any::operator=(
boost::any)
/usr/include/boost/any.hpp:75:15: note: no known conversion for argument 1
from ‘AnyTesting3()::BarrierType’ to ‘boost::any’
程序:
#include
#include
#include
#include | d****i 发帖数: 4809 | 2 Change the last line to
myPropertySet["BarrType"] = BarrierType::DownAndOut;
And then compile it using the -std switch
g++ -I/usr/local/boost_1_55_0 -o boost_any -std=c++0x boost_any.cpp
OR
g++ -I$BOOST_ROOT -o boost_any -std=c++0x boost_any.cpp
It should compile.
std:
boost
【在 k***p 的大作中提到】 : 我的compiler是gcc 4.7。 多谢 : $g++ testAny.cpp -o testAny : testAny.cpp: In function ‘void AnyTesting3()’: : testAny.cpp:66:54: error: no match for ‘operator=’ in ‘myPropertySet.std: : :map<_Key, _Tp, _Compare, _Alloc>::operator[], boost : ::any, std::less >, std::allocator: std::basic_string, boost::any> > >((* & std::basic_string((( : const char*)"BarrType"), (*(const std::allocator*)(& std::allocator< : char>()))))) = (BarrierType)0u’ : testAny.cpp:66:54: note: candidates are:
|
|