Closed bhyu0924 closed 2 years ago
I also met this problem. How did you solve it?
map::contains() is only available from C++20 (https://en.cppreference.com/w/cpp/container/map/contains), could you verify that your code is compiled with C++20?
thank you very much! i fixed this error by add
set(CMAKE_CXX_STANDARD 20)
in CMakeLists.txt.
but now i meet anothor problem:
/opt/ros/noetic/include/ros/serialization.h:385:82: error: no class template named ‘rebind’ in ‘class std::allocator<unsigned char>’ 385 | typedef std::vector<T, typename ContainerAllocator::template rebind<T>::other> VecType; ’
the full error information is:
`
[ 83%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///internal/hyper/system/components/frontends/visual/klt.cpp.o
In file included from /opt/ros/noetic/include/ros/publisher.h:34,
from /opt/ros/noetic/include/ros/node_handle.h:32,
from /home/sharine/LXX/MyResearch/CTSLAM/HyperSLAM/internal/hyper/system/components/module.cpp:7:
/opt/ros/noetic/include/ros/serialization.h: In instantiation of ‘struct ros::serialization::VectorSerializer<unsigned char, std::allocator~~
/opt/ros/noetic/include/ros/serialization.h:386:38: error: no class template named ‘rebind’ in ‘class std::allocator~~~
/opt/ros/noetic/include/ros/serialization.h:387:44: error: no class template named ‘rebind’ in ‘class std::allocator~~~~
In file included from /opt/ros/noetic/include/ros/publisher.h:34,
from /opt/ros/noetic/include/ros/node_handle.h:32,
from /home/sharine/LXX/MyResearch/CTSLAM/HyperSLAM/internal/hyper/system/components/module.cpp:7:
/opt/ros/noetic/include/ros/serialization.h: In instantiation of ‘void ros::serialization::deserialize(Stream&, std::vector<_Tp, _Alloc>&) [with T = unsigned char; ContainerAllocator = std::allocator~~~~~~~~~^~~
`
map::contains() is only available from C++20 (https://en.cppreference.com/w/cpp/container/map/contains), could you verify that your code is compiled with C++20?
now, the error is:
/opt/ros/noetic/include/ros/serialization.h:385:82: error: no class template named ‘rebind’ in ‘class std::allocator<unsigned char>’ 385 | typedef std::vector<T, typename ContainerAllocator::template rebind<T>::other> VecType;
it seems that ros noeotic ‘s serialization.h
uses std::allocator::rebind,
but it removed in C++20. std::allocator
but map::contains()
is only available from C++20.
so, how to solve this problem?
map::contains() is only available from C++20 (https://en.cppreference.com/w/cpp/container/map/contains), could you verify that your code is compiled with C++20?
what‘s your CMake version ?
map::contains() is only available from C++20 (https://en.cppreference.com/w/cpp/container/map/contains), could you verify that your code is compiled with C++20?
I saw that the standard C++ version (C++20) has already been set in CMakeLists.txt by:
set_target_properties(${PROJECT_NAME} PROPERTIES INTERFACE_CXX_STANDARD 20 INTERFACE_CXX_STANDARD_REQUIRED YES)
target_compile_options(${PROJECT_NAME} INTERFACE -Wall -Wextra -Wnon-virtual-dtor -pedantic)
target_compile_options(${PROJECT_NAME} INTERFACE -std=c++2a -march=native -O3 -fconcepts)
but if I not add set(CMAKE_CXX_STANDARD 20)
in CMakeLists.txt, it still report the error has no member named
contains`.
but if i add set(CMAKE_CXX_STANDARD 20)
in CMakeLists.txt, ros neotic report error:
/opt/ros/noetic/include/ros/serialization.h:385:82: error: no class template named ‘rebind’ in ‘class std::allocator<unsigned char>’
/opt/ros/noetic/include/ros/serialization.h:485:48: error: ‘read’ is not a member of ‘ros::serialization::VectorSerializer<unsigned char, std::allocator<unsigned char>, void>’
My system's Cmake version is cmake version 3.22.1
map::contains() is only available from C++20 (https://en.cppreference.com/w/cpp/container/map/contains), could you verify that your code is compiled with C++20?
In my case, the issue was resolved by adding " set(CMAKE_CXX_STANDARD 20) " in CMakeLists.txt
For later visitors, my local env left here.
Ubuntu 18.04 / ROS1 melodic / gcc & g++ 9.4.0 / cmake version 3.22.1
Thanks a lot.
@bhyu0924 and @SharineLee Thank you for your input. We will update the CMake file in a reiterated version and make sure that the CMAKE_CXX_STANDARD 20
is properly propagated without having to add set(CMAKE_CXX_STANDARD 20)
aside from the already defined INTERFACE_CXX_STANDARD 20
.
Great! I look forward to updating soon 👍
Thanks for your nice work.
I would like to run your code on my desktop. However, make failed with the error messages below. Note that CMake was successfully done. I am working on Ubuntu 18.04 / ROS Melodic
TIA.
[ 3%] Building CXX object _deps/hyperstate-build/CMakeFiles/HyperState.dir/internal/hyper/state/interpolators/basis.cpp.o [ 3%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir/main.cpp.o [ 3%] Building CXX object _deps/hyperstate-build/CMakeFiles/HyperState.dir/internal/hyper/state/interpolators/polynomial.cpp.o [ 4%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/internal/hyper/variables/distortions/distortion_tests.cpp.o [ 5%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/internal/hyper/variables/groups/se3_tests.cpp.o [ 5%] Built target HyperSystem [ 6%] Building CXX object _deps/hyperstate-build/CMakeFiles/HyperState.dir/internal/hyper/state/abstract.cpp.o [ 6%] Built target HyperSensors [ 7%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/internal/hyper/variables/groups/su2_tests.cpp.o [ 8%] Building CXX object _deps/hyperstate-build/CMakeFiles/HyperState.dir/internal/hyper/state/policies/se3.cpp.o [ 9%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/internal/hyper/variables/intrinsics_tests.cpp.o [ 10%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/internal/hyper/variables/metrics/metrics_tests.cpp.o [ 11%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/internal/hyper/variables/orthonormality_alignment_tests.cpp.o [ 12%] Building CXX object _deps/hypervariables-build/apps/tests/CMakeFiles/HyperVariablesTests.dir///tests/plugins/matrix_base_plugin_tests.cpp.o [ 13%] Linking CXX shared library ../../../lib/libHyperState.so [ 13%] Built target HyperState [ 14%] Building CXX object apps/hyperslam/CMakeFiles/HyperSLAM.dir/main.cpp.o [ 15%] Building CXX object _deps/hyperstate-build/apps/tests/CMakeFiles/HyperStateTests.dir/main.cpp.o [ 16%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir/main.cpp.o [ 17%] Building CXX object _deps/hyperstate-build/apps/tests/CMakeFiles/HyperStateTests.dir///tests/internal/hyper/range_tests.cpp.o [ 18%] Building CXX object _deps/hyperstate-build/apps/tests/CMakeFiles/HyperStateTests.dir///tests/internal/hyper/state/interpolators/basis_tests.cpp.o [ 19%] Building CXX object _deps/hyperstate-build/apps/tests/CMakeFiles/HyperStateTests.dir///tests/internal/hyper/state/state_tests.cpp.o [ 20%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/messages/abstract.cpp.o [ 21%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/messages/measurements/abstract.cpp.o [ 22%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/messages/visual.cpp.o [ 23%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/sensors/camera.cpp.o [ 25%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/sensors/imu.cpp.o [ 26%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/sensors/sensor.cpp.o [ 27%] Building CXX object _deps/hypersensors-build/apps/tests/CMakeFiles/HyperSensorsTests.dir///internal/hyper/yaml/yaml.cpp.o [ 28%] Building CXX object apps/hyperslam/CMakeFiles/HyperSLAM.dir///internal/hyper/environment/abstract.cpp.o [ 29%] Linking CXX executable ../../../../../bin/HyperVariablesTests [ 30%] Building CXX object apps/hyperslam/CMakeFiles/HyperSLAM.dir///internal/hyper/environment/landmarks/abstract.cpp.o [ 30%] Built target HyperVariablesTests [ 31%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir/main.cpp.o [ 32%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///tests/internal/tests/optimizers/evaluators/bearing.cpp.o [ 33%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///tests/internal/tests/optimizers/evaluators/inertial.cpp.o [ 34%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///tests/internal/tests/optimizers/evaluators/manifold.cpp.o In file included from /home/yurl18/grad/hyper_ws/src/HyperSLAM/build/_deps/hypervariables-src/include/hyper/variables/groups/su2.hpp:6, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/build/_deps/hypervariables-src/include/hyper/variables/groups/se3.hpp:6, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/build/_deps/hypersensors-src/include/hyper/sensors/forward.hpp:9, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/include/hyper/environment/landmarks/abstract.hpp:11, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/internal/hyper/environment/landmarks/abstract.cpp:4: /home/yurl18/grad/hyper_ws/src/HyperSLAM/internal/hyper/environment/landmarks/abstract.cpp: In member function ‘hyper::AbstractLandmark::ObservationSet& hyper::AbstractLandmark::observations(const hyper::Sensor&) const’: /home/yurl18/grad/hyper_ws/src/HyperSLAM/internal/hyper/environment/landmarks/abstract.cpp:29:27: error: ‘using ObservationMap = class std::map<const hyper::Sensor, std::set<const hyper::AbstractObservation, hyper::AbstractLandmark::AbstractObservationCompare> >’ {aka ‘class std::map<const hyper::Sensor, std::set<const hyper::AbstractObservation, hyper::AbstractLandmark::AbstractObservationCompare> >’} has no member named ‘contains’ 29 | DCHECK(observationmap.contains(p_sensor)); | ^
~~~ apps/hyperslam/CMakeFiles/HyperSLAM.dir/build.make:103: recipe for target 'apps/hyperslam/CMakeFiles/HyperSLAM.dir///internal/hyper/environment/landmarks/abstract.cpp.o' failed make[2]: [apps/hyperslam/CMakeFiles/HyperSLAM.dir///internal/hyper/environment/landmarks/abstract.cpp.o] Error 1 make[2]: Waiting for unfinished jobs.... [ 35%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///tests/internal/tests/optimizers/evaluators/pixel.cpp.o [ 36%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///internal/hyper/environment/abstract.cpp.o CMakeFiles/Makefile2:1072: recipe for target 'apps/hyperslam/CMakeFiles/HyperSLAM.dir/all' failed make[1]: [apps/hyperslam/CMakeFiles/HyperSLAM.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... [ 37%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///internal/hyper/environment/landmarks/abstract.cpp.o [ 38%] Linking CXX executable ../../../../../bin/HyperStateTests [ 38%] Built target HyperStateTests [ 39%] Building CXX object apps/tests/CMakeFiles/HyperSystemTests.dir///internal/hyper/environment/observations/landmark.cpp.o In file included from /home/yurl18/grad/hyper_ws/src/HyperSLAM/build/_deps/hypervariables-src/include/hyper/variables/groups/su2.hpp:6, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/build/_deps/hypervariables-src/include/hyper/variables/groups/se3.hpp:6, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/build/_deps/hypersensors-src/include/hyper/sensors/forward.hpp:9, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/include/hyper/environment/landmarks/abstract.hpp:11, from /home/yurl18/grad/hyper_ws/src/HyperSLAM/internal/hyper/environment/landmarks/abstract.cpp:4: /home/yurl18/grad/hyper_ws/src/HyperSLAM/internal/hyper/environment/landmarks/abstract.cpp: In member function ‘hyper::AbstractLandmark::ObservationSet& hyper::AbstractLandmark::observations(const hyper::Sensor&) const’: /home/yurl18/grad/hyper_ws/src/HyperSLAM/internal/hyper/environment/landmarks/abstract.cpp:29:27: error: ‘using ObservationMap = class std::map<const hyper::Sensor, std::set<const hyper::AbstractObservation, hyper::AbstractLandmark::AbstractObservationCompare> >’ {aka ‘class std::map<const hyper::Sensor, std::set<const hyper::AbstractObservation, hyper::AbstractLandmark::AbstractObservationCompare> >’} has no member named ‘contains’ 29 | DCHECK(observationmap.contains(p_sensor)); | ^~~~ apps/tests/CMakeFiles/HyperSystemTests.dir/build.make:159: recipe for target 'apps/tests/CMakeFiles/HyperSystemTests.dir///internal/hyper/environment/landmarks/abstract.cpp.o' failed make[2]: [apps/tests/CMakeFiles/HyperSystemTests.dir///internal/hyper/environment/landmarks/abstract.cpp.o] Error 1 make[2]: Waiting for unfinished jobs.... [ 40%] Linking CXX executable ../../../../../bin/HyperSensorsTests [ 40%] Built target HyperSensorsTests CMakeFiles/Makefile2:1100: recipe for target 'apps/tests/CMakeFiles/HyperSystemTests.dir/all' failed make[1]: [apps/tests/CMakeFiles/HyperSystemTests.dir/all] Error 2 Makefile:90: recipe for target 'all' failed make: [all] Error 2