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::text::v1, and one in boost::text::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.Text 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::text::foo, and you will get boost::text::v1::foo when building in C++14 or C++17 modes, and boost::text::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.Text's C++20 code, you can disable the v2 namespace by defining BOOST_TEXT_DISABLE_CONCEPTS.


PrevUpHomeNext