...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
![]() |
Caution |
---|---|
C++20 module support is on early stage, targets, flags and behavior may change in the future |
If using modern CMake define CMake option -DBOOST_USE_MODULES=1
to build a C++20 module and make the Boost::any
CMake target provide it. After that an explicit usage of C++20 module boost.any
is allowed:
import boost.any; int main() { boost::any a = 42; }
The Boost::any
CMake target gives an ability to mix
includes and imports of the library in different translation units. Moreover,
if BOOST_USE_MODULES
macro
is defined then all the boost/any...
includes implicilty do import boost.any;
to give all the benifits of modules without
changing the existing code.
![]() |
Note |
---|---|
For better compile times make sure that |
If not using CMake, then the module could be build manually from the modules/boost_any.cppm
file.
For manual module build the following commands could be used for clang compiler:
cd any/modules clang++ -I ../include -std=c++20 --precompile -x c++-module boost_any.cppm
After that, the module could be used in the following way:
clang++ -std=c++20 -fmodule-file=boost_any.pcm boost_any.pcm usage_sample.cpp