Build issue no member named clamp in namespace std
fspindle opened this issue · comments
When ViSP is build with c++17 standard and used as a 3rd party projet where standard is explicitly set to c++14 or c++11 build fails.
% make
[ 50%] Building CXX object CMakeFiles/testMath.dir/testMath.cpp.o
In file included from /Users/fspindle/soft/test/test-clamp/testMath.cpp:46:
/Users/fspindle/soft/visp/visp_ws/test-pr/visp-fspindle/visp-fix/modules/core/include/visp3/core/vpMath.h:219:12: error: no member named 'clamp' in namespace 'std'; did you mean simply 'clamp'?
return std::clamp(v, lower, upper);
^~~~~~~~~~
clamp
/Users/fspindle/soft/visp/visp_ws/test-pr/visp-fspindle/visp-fix/modules/core/include/visp3/core/vpMath.h:216:41: note: 'clamp' declared here
template <typename T> static inline T clamp(const T &v, const T &lower, const T &upper)
^
1 error generated.
To reproduce, create a project with testMath.cpp
and the following CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.5)
project(test)
find_package(VISP)
set(CMAKE_CXX_STANDARD 14)
add_executable(testMath testMath.cpp)
target_link_libraries(testMath ${VISP_LIBRARIES})
include_directories(testMath ${VISP_INCLUDE_DIRS})