Anyone know why sudo cmake --build ./build-clang --config Release
results in
In file included from /opt/local/include/boost/asio/buffer.hpp:29:
/opt/local/include/boost/asio/detail/type_traits.hpp:89:12: error: no member named 'result_of' in namespace 'std'
using std::result_of;
~~~~~^
Despite the env variables being set?
$CC=clang
$CXX=clang++
$CC --version
Homebrew clang version 15.0.6
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
trying to build for Mac for the first time.
boost was installed using macports sudo port install boost +universal
I've heard result_of was deprecated in C++17 and removed in C++20 – how can I get around this issue? I'm working with C++20
when I add
target_compile_definitions(${TARGET_NAME}
PRIVATE
BOOST_ASIO_HAS_STD_INVOKE_RESULT=1)
I get the same errors
I uninstalled and reinstalled the latest version using brew
and now I get /opt/local/include/cpprest/http_client.h:68:10: fatal error: 'boost/asio/ssl.hpp' file not found #include "boost/asio/ssl.hpp"
The problem is that at the moment, MacPorts only supports up to Boost 1.76. By default, it will use std::result_of
, which has been removed in C++20.
To solve this, you can manually define BOOST_ASIO_HAS_STD_INVOKE_RESULT
, which should route usages of result_of
to the C++20 compliant invoke_result
within the source.
Note, this does not guarantee all other codes are C++20 compliant.
Alternatively, you can also manually install Boost, or install it through other package managers like Homebrew, which supports up to Boost 1.81