Configuration Macros
User Configurable Macros
The following configuration macros are available:
-
BOOST_DECIMAL_DISABLE_CASSERT: Disables the use of<cassert>and all run-time assertions. -
BOOST_DECIMAL_DISABLE_IOSTREAM: Disables the use of I/O streaming and removes all associated headers (e.g.<iostream>,<iosfwd>,<cwchar>, etc.) -
BOOST_DECIMAL_DISABLE_CLIB: Defines both of the above macros. In testing this reduces ROM usage by ~50% and can be useful if running on embedded platforms. -
BOOST_DECIMAL_DISABLE_EXCEPTIONS: This allows the user to disable any calls tothrow. This macro will also be set automatically in the presence of-fno-exceptionsor various/EHflags on MSVC. -
BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS: Allows any integer type to be implicitly converted to any decimal type. -
BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS: Allows a binary floating-point type (e.g.double) to be implicitly converted to a decimal floating point type. This option is not recommended, but can be useful if you want to use specific functionality from the standard library with internal conversions such as:
#define BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS
#include <boost/decimal.hpp>
#include <complex>
constexpr decimal64_t half {5, -1};
std::complex<decimal64_t> test_val {half, half};
const auto res = std::acos(test_val);
-
BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS: Defines bothBOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONSandBOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS -
BOOST_DECIMAL_FAST_MATHperforms optimizations similar to that of the-ffast-mathcompiler flag such as removing all checks for non-finite values. This flag increases the performance of the basis operations (e.g. add, sub, mul, div, and comparisons) by up to 20%. Again, it must be defined before inclusion of decimal headers like so:
#define BOOST_DECIMAL_FAST_MATH
#include <boost/decimal.hpp>
-
BOOST_DECIMAL_DEC_EVAL_METHOD: See<cfloat>section for explanation
-
BOOST_DECIMAL_ENABLE_CUDA: Defining this macro allows both the types and selected functions to be run on host and device when compiling with NVCC (i.e. when__CUDACC__is defined). Allowed functions haveBOOST_DECIMAL_HOST_DEVICEorBOOST_DECIMAL_CUDA_CONSTEXPRas part of their function signature. Defining this macro also automatically definesBOOST_DECIMAL_DISABLE_EXCEPTIONSandBOOST_DECIMAL_DISABLE_CASSERT, since neither exceptions nor<cassert>are available in device code.
Automatic Configuration Macros
-
BOOST_DECIMAL_CXX20_CONSTEXPR: This is defined toconstexprwhen compiling with C++20 or greater, otherwise it expands to nothing.
-
BOOST_DECIMAL_HOST_DEVICE: This is defined to__host__ __device__when compiling with NVCC andBOOST_DECIMAL_ENABLE_CUDAis defined, and to nothing otherwise. Public functions, constructors, operators, and conversion operators annotated with this macro can be used in CUDA device code without modification.
-
BOOST_DECIMAL_CUDA_CONSTEXPR: This is defined to__host__ __device__ constexprwhen compiling with NVCC andBOOST_DECIMAL_ENABLE_CUDAis defined, and toconstexprotherwise. The majority of the library’s functions are annotated with this macro. -
BOOST_DECIMAL_HAS_STD_CHARCONV: This macro is defined if header<charconv>exists and the language standard used is >= C++17-
We only need the structs and enums out of the header so we are not concerned with being overly restrictive about the feature test macros.
-
Known compilers that support this lighter requirement are: GCC >= 10, Clang >= 13, and MSVC >= 14.2
-
-
-
BOOST_DECIMAL_HAS_STD_STRING_VIEW: This macro is defined if header<string_view>exists and the langauge standard used is >= C++17