boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
101 stars 113 forks source link

pmr cannot handle enum typedefs #182

Closed BenniProbst closed 3 years ago

BenniProbst commented 3 years ago

/usr/bin/ld: CMakeFiles/Kodierungstheorie.dir/main.cpp.o: in function boost::container::pmr::polymorphic_allocator<boost::container::dtl::pair<intern_enum, int> >::polymorphic_allocator()': /home/benjamin-elias/Downloads/boost_1_75_0/boost/container/pmr/polymorphic_allocator.hpp:46: undefined reference toboost::container::pmr::get_default_resource()' /usr/bin/ld: CMakeFiles/Kodierungstheorie.dir/main.cpp.o: in function boost::container::pmr::polymorphic_allocator<int>::polymorphic_allocator()': /home/benjamin-elias/Downloads/boost_1_75_0/boost/container/pmr/polymorphic_allocator.hpp:46: undefined reference toboost::container::pmr::get_default_resource()' /usr/bin/ld: CMakeFiles/Kodierungstheorie.dir/main.cpp.o: in function boost::container::pmr::polymorphic_allocator<boost::container::stable_vector_detail::node_base<void*>*>::polymorphic_allocator()': /home/benjamin-elias/Downloads/boost_1_75_0/boost/container/pmr/polymorphic_allocator.hpp:46: undefined reference toboost::container::pmr::get_default_resource()' /usr/bin/ld: CMakeFiles/Kodierungstheorie.dir/main.cpp.o: in function boost::container::pmr::polymorphic_allocator<boost::container::stable_vector_detail::node<int*> >::polymorphic_allocator()': /home/benjamin-elias/Downloads/boost_1_75_0/boost/container/pmr/polymorphic_allocator.hpp:46: undefined reference toboost::container::pmr::get_default_resource()' /usr/bin/ld: CMakeFiles/Kodierungstheorie.dir/main.cpp.o: in function boost::container::pmr::polymorphic_allocator<int*>::polymorphic_allocator()': /home/benjamin-elias/Downloads/boost_1_75_0/boost/container/pmr/polymorphic_allocator.hpp:46: undefined reference toboost::container::pmr::get_default_resource()' /usr/bin/ld: CMakeFiles/Kodierungstheorie.dir/main.cpp.o:/home/benjamin-elias/Downloads/boost_1_75_0/boost/container/pmr/polymorphic_allocator.hpp:46: more undefined references to `boost::container::pmr::get_default_resource()' follow collect2: error: ld returned 1 exit status make[3]: [CMakeFiles/Kodierungstheorie.dir/build.make:103: Kodierungstheorie] Error 1 make[2]: [CMakeFiles/Makefile2:95: CMakeFiles/Kodierungstheorie.dir/all] Error 2 make[1]: [CMakeFiles/Makefile2:102: CMakeFiles/Kodierungstheorie.dir/rule] Error 2 make: [Makefile:137: Kodierungstheorie] Error 2

with enums

typedef enum { VECTOR, DEQUE, SLIST, LIST, AUTO } mode_enum; typedef enum { VEC, DEQ, SL, L } intern_enum;

the key of a pmr map should be converted to int to fit, if enum is inserted and type should be checked to be correct if retrieved

BenniProbst commented 3 years ago

Main issue at typedef boost::container::pmr::flat_map<intern_enum, int> map_t; map_t statistics{{static_cast(VEC), 0}, {static_cast(DEQ), 0}, {static_cast(SL), 0}, {static_cast(L), 0}};

igaztanaga commented 3 years ago

I can't see any relationship between enums and linker errors. The linker complains because you need to link boost.container library (https://www.boost.org/doc/libs/1_76_0/doc/html/container.html#container.intro.introduction_building_container). Could you please provide a minimal test case and detail the environment (OS, compiler version, etc.)?

BenniProbst commented 3 years ago

I use Linux mint 20.1 , GCC 10.2.2 . It was late, It's probably my fault. I could not call with an enum type out of list.

igaztanaga commented 3 years ago

Since I can't reproduce the bug I'm closing it, please reopen it if you manage to have a minimal test case showing the bug.