hi,
i can build a map, but not a boost::ptr_map.
could someone please help?
thank you,
e.
#include
using std::map;
using std::cout;
using std::endl;
class A{
public:
A(double x_):x(x_){};
const double x;
};
int main(){
map map_A; //cannot use map
//because A() not defined
//why? because A has const members.
A a(0.0);
map_A[0]=new A(0.0);//fine
boost::ptr_map ptr_map_A;
ptr_map_A[0]=new A(0.0);//not fine
return 0;
};
**** Build of configuration Debug for project testing_map ****
make -k all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/boost_1_34_1 -O0 -g3 -Wall -c -fmessage-length=0 -MMD
-MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
../main.cpp:25:3: warning: no newline at end of file
../main.cpp: In function ‘int main()’:
../main.cpp:22: error: no match for ‘operator=’ in
‘ptr_map_A.boost::ptr_map > >::<anonymous>.boost::ptr_map_adapter > >,
boost::heap_clone_allocator>::<anonymous>.boost::ptr_container_detail::ptr_map_adapter_base::operator[] [with T = A, VoidPtrMap =
std::map > >, CloneAllocator
= boost::heap_clone_allocator](((const unsigned int&)((const unsigned
int*)(&0u)))) = (((A*)operator new(8u)), (<anonymous>->A::A(0.0),
<anonymous>))’
../header.h:4: note: candidates are: A& A::operator=(const A&)
/usr/local/boost_1_34_1/boost/ptr_container/ptr_map_adapter.hpp: In
member function ‘typename
boost::ptr_container_detail::associative_ptr_container, CloneAllocator>::reference
boost::ptr_container_detail::ptr_map_adapter_base::insert_lookup(const typename
boost::ptr_container_detail::associative_ptr_container, CloneAllocator>::key_type&) [with T = A, VoidPtrMap =
std::map > >, CloneAllocator
= boost::heap_clone_allocator]’:
/usr/local/boost_1_34_1/boost/ptr_container/ptr_map_adapter.hpp:268:
instantiated from ‘typename
boost::ptr_container_detail::associative_ptr_container, CloneAllocator>::reference
boost::ptr_container_detail::ptr_map_adapter_base::operator[](const typename
boost::ptr_container_detail::associative_ptr_container, CloneAllocator>::key_type&) [with T = A, VoidPtrMap =
std::map > >, CloneAllocator
= boost::heap_clone_allocator]’
../main.cpp:22: instantiated from here
/usr/local/boost_1_34_1/boost/ptr_container/ptr_map_adapter.hpp:168:
error: no matching function for call to ‘A::A()’
../header.h:6: note: candidates are: A::A(double)
../header.h:4: note: A::A(const A&)
make: *** [main.o] Error 1
make: Target `all' not remade because of errors.
Build complete for project testing_map