# Common concepts¶

Note

Generic functions and classes in mp++ support concepts to constrain the types with which they can be used. C++ concepts are part of the C++20 standard, and they are currently available only in GCC 6 and later (with the -fconcepts compilation flag), and on the very latest Clang and MSVC snapshots. When used with compilers which do not support concepts natively, mp++ will employ a concept emulation layer in order to provide the same functionality as native C++ concepts.

Since the syntax of native C++ concepts is clearer than that of the concept emulation layer, the mp++ documentation describes and refers to concepts in their native C++ form.

#include <mp++/concepts.hpp>

template<typename T>
concept mppp::CppInteroperable

This concept is satisfied by any C++ fundamental type with which the multiprecision classes (such as integer, rational, etc.) can interoperate. The full list of types satisfying this concept includes:

• all the fundamental C++ integral types,

• float and double.

long double is also included, but only if mp++ was configured with the MPPP_WITH_MPFR option enabled (see the installation instructions).

The GCC-style extended 128-bit integral types __int128_t and __uint128_t are included as well, if supported on the current platform/compiler combination (see also the MPPP_HAVE_GCC_INT128 definition).

A corresponding boolean type trait called is_cpp_interoperable is also available (even if the compiler does not support concepts).

template<typename T>
concept mppp::CppIntegralInteroperable

This concept is satisfied if T is an integral CppInteroperable type.

A corresponding boolean type trait called is_cpp_integral_interoperable is also available (even if the compiler does not support concepts).

template<typename T>
concept mppp::CppUnsignedIntegralInteroperable

This concept is satisfied if T is an unsigned integral CppInteroperable type.

A corresponding boolean type trait called is_cpp_unsigned_integral_interoperable is also available (even if the compiler does not support concepts).

template<typename T>
concept mppp::CppSignedIntegralInteroperable

This concept is satisfied if T is a signed integral CppInteroperable type.

A corresponding boolean type trait called is_cpp_signed_integral_interoperable is also available (even if the compiler does not support concepts).

template<typename T>
concept mppp::CppFloatingPointInteroperable

This concept is satisfied if T is a floating-point CppInteroperable type.

A corresponding boolean type trait called is_cpp_floating_point_interoperable is also available (even if the compiler does not support concepts).

template<typename T>
concept mppp::StringType

This concept is satisfied by C++ string-like types. Specifically, the concept will be true if T, after the removal of cv qualifiers, is one of the following types:

• std::string,

• a pointer to (possibly cv qualified) char,

• a char array of any size.

Additionally, if at least C++17 is being used, the concept is satisfied also by std::string_view.