Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

The v1 and v2 Namespaces, and the Use of C++20 Concepts

For much of this library, there are two interfaces: one in namespace boost::stl_interfaces::v1, and one in boost::stl_interfaces::v2. The v1 version uses SFINAE to constrain templates, and the v2 version uses concepts, including the standard concepts from C++20.

When you build with a conforming C++20 compiler, the compiler defines a macro __cpp_lib_concepts that indicates that the compiler supports concepts, and provides the standard concepts in std and std::ranges. When Boost.STLInterfaces sees the __cpp_lib_concepts macro defined, it inlines the v2 namespace; otherwise, it inlines the v1 namespace.

The net result for you as a user is that, for some function or type foo with v1 and v2 versions, you can use boost::stl_interfaces::foo, and you will get boost::stl_interfaces::v1::foo when building in C++14 or C++17 modes, and boost::stl_interfaces::v2::foo when building in C++20 or later.

If you are using an early C++20 implementation that claims to have concept support, but that breaks when you build Boost.STLInterfaces's C++20 code, you can disable the v2 namespace by defining BOOST_STL_INTERFACES_DISABLE_CONCEPTS. ]


PrevUpHomeNext