Preprocessor module

Compiler feature detection, attributes, string-makers, etc.

Defines

#define MUU_ABSTRACT_INTERFACE
Marks a class being interface-only and not requiring a vtable.
#define MUU_ALWAYS_INLINE
The same linkage semantics as the inline keyword, with an additional hint to the optimizer that you'd really, really like a function inlined.
#define MUU_ARCH_AMD64
1 when targeting AMD64, otherwise 0.
#define MUU_ARCH_ARM
1 when targeting any flavour of ARM, otherwise 0.
#define MUU_ARCH_ARM32
1 when targeting 32-bit ARM, otherwise 0.
#define MUU_ARCH_ARM64
1 when targeting 64-bit ARM, otherwise 0.
#define MUU_ARCH_BITNESS
The 'bitness' of the target architecture (e.g. 64 on AMD64).
#define MUU_ARCH_ITANIUM
1 when targeting 64-bit Itanium, otherwise 0.
#define MUU_ARCH_X64
1 when targeting any 64-bit architecture, otherwise 0.
#define MUU_ARCH_X86
1 when targeting 32-bit x86, otherwise 0.
#define MUU_ASSUME(expr)
Optimizer hint for signalling various assumptions about state at specific points in code.
#define MUU_ATTR(...)
Expands to __attribute__(( ... )) when compiling with a compiler that supports GNU-style attributes.
#define MUU_ATTR_CLANG(...)
Expands to __attribute__(( ... )) when compiling with Clang.
#define MUU_ATTR_CLANG_GE(ver, ...)
Expands to __attribute__(( ... )) when compiling with Clang and __clang_major__ >= ver.
#define MUU_ATTR_CLANG_LT(ver, ...)
Expands to __attribute__(( ... )) when compiling with Clang and __clang_major__ < ver.
#define MUU_ATTR_GCC(...)
Expands to __attribute__(( ... )) when compiling with GCC.
#define MUU_ATTR_GCC_GE(ver, ...)
Expands to __attribute__(( ... )) when compiling with GCC and __GNUC__ >= ver.
#define MUU_ATTR_GCC_LT(ver, ...)
Expands to __attribute__(( ... )) when compiling with GCC and __GNUC__ < ver.
#define MUU_ATTR_NDEBUG(...)
Expands to __attribute__(( ... )) when compiling with a compiler that supports GNU-style attributes and NDEBUG is defined.
#define MUU_BIG_ENDIAN
1 when the target environment is big-endian, otherwise 0.
#define MUU_CLANG
The value of __clang_major__ when the code is being compiled by LLVM/Clang, otherwise 0.
#define MUU_CONCAT(x, y)
Concatenates two preprocessor inputs. Equivalent to the ## operator, but with macro expansion.
#define MUU_CONSTEVAL
Expands to C++20's consteval if supported by your compiler, otherwise constexpr.
#define MUU_CPP
The currently-targeted C++ standard. 17 for C++17, 20 for C++20, etc.
#define MUU_CUDA
1 when compiled with nVIDIA's CUDA compiler, otherwise 0.
#define MUU_DECLSPEC(...)
Expands to __declspec( ... ) when compiling with MSVC (or another compiler in MSVC-mode).
#define MUU_DEFAULT_COPY(T)
Explicitly defaults the copy constructor and copy-assignment operator of a class or struct.
#define MUU_DEFAULT_MOVE(T)
Explicitly defaults the move constructor and move-assignment operator of a class or struct.
#define MUU_DELETE_COPY(T)
Explicitly deletes the copy constructor and copy-assignment operator of a class or struct.
#define MUU_DELETE_MOVE(T)
Explicitly deletes the move constructor and move-assignment operator of a class or struct.
#define MUU_DISABLE_ARITHMETIC_WARNINGS
Disables compiler warnings relating to integer and floating-point arithmetic.
#define MUU_DISABLE_CODE_ANALYSIS_WARNINGS
Disables interactive code analysis warnings (e.g. Visual Studio's background analysis engine).
#define MUU_DISABLE_DEPRECATION_WARNINGS
Disables compiler warnings relating to deprecated functions, types, etc.
#define MUU_DISABLE_LIFETIME_WARNINGS
Disables compiler warnings relating to object lifetime (initialization, destruction, magic statics, et cetera).
#define MUU_DISABLE_SHADOW_WARNINGS
Disables compiler warnings relating to variable, class and function name shadowing.
#define MUU_DISABLE_SPAM_WARNINGS
Disables compiler warnings that are generally spammy/superfluous (padding, double promotion, cast alignment, etc.)
#define MUU_DISABLE_SUGGESTION_WARNINGS
Disables compiler warnings resulting from -Wsuggest=... and friends.
#define MUU_DISABLE_SWITCH_WARNINGS
Disables compiler warnings relating to the use of switch statements.
#define MUU_DISABLE_WARNINGS
Pushes the current compiler warning state onto the stack then disables ALL compiler warnings.
#define MUU_DOXYGEN
1 when the code being interpreted by Doygen or some other documentation generator, otherwise 0.
#define MUU_EMPTY_BASES
Marks a class as having only empty base classes.
#define MUU_ENABLE_WARNINGS
Re-enables compiler warnings again after using MUU_DISABLE_WARNINGS.
#define MUU_GCC
The value of __GNUC__ when the code is being compiled by GCC specifically, otherwise 0.
#define MUU_GCC_LIKE
The value of __GNUC__ when it is defined by the compiler, otherwise 0.
#define MUU_HAS_ATTR(attr)
The result of __has_attribute(attr) if supported by the compiler, otherwise 0.
#define MUU_HAS_BUILTIN(name)
The result of __has_builtin(name) if supported by the compiler, otherwise 0.
#define MUU_HAS_CHAR8
1 when the compiler supports C++20's char8_t, otherwise 0.
#define MUU_HAS_CONSTEVAL
1 when the compiler supports C++20's consteval immediate functions, otherwise 0.
#define MUU_HAS_CPP_ATTR(attr)
The result of __has_cpp_attribute(attr) if supported by the compiler, otherwise 0.
#define MUU_HAS_EXCEPTIONS
1 when C++ exceptions are supported and enabled, otherwise 0.
#define MUU_HAS_FEATURE(name)
The result of __has_feature(name) if supported by the compiler, otherwise 0.
#define MUU_HAS_FIXED_STRING_LITERALS
Indicates whether muu::fixed_string string literals (e.g. "hello"_fs) are supported by the compiler.
#define MUU_HAS_FLOAT128
1 when the target environment has 128-bit floats, otherwise 0.
#define MUU_HAS_FLOAT16
1 when the target environment has the 16-bit floating point type _Float16.
#define MUU_HAS_FP16
1 when the target environment has the storage-only 16-bit floating point type __fp16.
#define MUU_HAS_IF_CONSTEVAL
1 when the compiler supports C++23's if consteval { }, otherwise 0.
#define MUU_HAS_INCLUDE(header)
The result of __has_include(header) if supported by the compiler, otherwise 0.
#define MUU_HAS_INT128
1 when the target environment has 128-bit integers, otherwise 0.
#define MUU_HAS_RTTI
1 when C++ run-time type identification (RTTI) is supported and enabled, otherwise 0.
#define MUU_ICC
The value of __INTEL_COMPILER when the code is being compiled by ICC, otherwise 0.
#define MUU_IF_CONSTEVAL
Begins an if consteval block if supported, otherwise falls back on muu::is_constant_evaluated().
#define MUU_IF_RUNTIME
Begins an if !consteval block if supported, otherwise falls back on muu::is_constant_evaluated().
#define MUU_INTELLISENSE
1 when the code being compiled by an IDE's 'intellisense' compiler, otherwise 0.
#define MUU_ISET_AVX
1 when the target supports the AVX instruction set, otherwise 0.
#define MUU_ISET_AVX2
1 when the target supports the AVX2 instruction set, otherwise 0.
#define MUU_ISET_AVX512
1 when the target supports any of the AVX512 instruction sets, otherwise 0.
#define MUU_ISET_MMX
1 when the target supports the MMX instruction set, otherwise 0.
#define MUU_ISET_SSE
1 when the target supports the SSE instruction set, otherwise 0.
#define MUU_ISET_SSE2
1 when the target supports the SSE2 instruction set, otherwise 0.
#define MUU_LIKELY(...)
Expands a conditional to include an optimizer intrinsic (or C++20's [
  • ], if available) indicating that an if/else conditional is the likely path.
  • #define MUU_LINUX
    1 when building for a Linux distro, otherwise 0.
    #define MUU_LITTLE_ENDIAN
    1 when the target environment is little-endian, otherwise 0.
    #define MUU_MAKE_FLAGS(T)
    Stamps out operators for enum 'flags' types.
    #define MUU_MAKE_RAW_STRING(s)
    Stringifies the input, converting it verbatim into a raw string literal.
    #define MUU_MAKE_STRING(s)
    Stringifies the input, converting it into a string literal.
    #define MUU_MAKE_STRING_VIEW(s)
    Stringifies the input, converting it verbatim into a raw string view literal.
    #define MUU_MALLOC
    Optimizer hint that marks an allocating function's pointer return value as representing a newly allocated memory region free from aliasing.
    #define MUU_MSVC
    The value of _MSC_VER when the code is being compiled by MSVC specifically, otherwise 0.
    #define MUU_MSVC_LIKE
    The value of _MSC_VER when it is defined by the compiler, otherwise 0.
    #define MUU_NEVER_INLINE
    A strong hint to the optimizer that you really, really do not want a function inlined.
    #define MUU_NODISCARD
    Expands to [[nodiscard]] or __attribute__((warn_unused_result)).
    #define MUU_NODISCARD_CTOR
    Expands to [[nodiscard]] if your compiler supports it on constructors.
    #define MUU_NOOP
    Expands to a no-op expression.
    #define MUU_NO_UNIQUE_ADDRESS
    Expands to C++20's [[no_unique_address]] if supported by your compiler.
    #define MUU_PAUSE()
    Expands to a platform-specific intrinsic for pausing/yielding the CPU (e.g. _mm_pause()).
    #define MUU_POP_WARNINGS
    Pops the current compiler warning state off the stack.
    #define MUU_PRAGMA_CLANG(...)
    Expands to _Pragma("clang ...") when compiling with Clang.
    #define MUU_PRAGMA_CLANG_GE(ver, ...)
    Expands to _Pragma("clang ...") when compiling with Clang and __clang_major__ >= ver.
    #define MUU_PRAGMA_CLANG_LT(ver, ...)
    Expands to _Pragma("clang ...") when compiling with Clang and __clang_major__ < ver.
    #define MUU_PRAGMA_GCC(...)
    Expands to _Pragma("GCC ...") when compiling with GCC.
    #define MUU_PRAGMA_GCC_GE(ver, ...)
    Expands to _Pragma("GCC ...") when compiling with GCC and __GNUC__ >= ver.
    #define MUU_PRAGMA_GCC_LT(ver, ...)
    Expands to _Pragma("GCC ...") when compiling with GCC and __GNUC__ < ver.
    #define MUU_PRAGMA_ICC(...)
    Expands to _pragma(...) when compiling with ICC.
    #define MUU_PRAGMA_MSVC(...)
    Expands to __pragma(...) when compiling with MSVC.
    #define MUU_PRAGMA_MSVC_GE(ver, ...)
    Expands to __pragma(...) when compiling with MSVC and _MSC_VER >= ver.
    #define MUU_PRAGMA_MSVC_LT(ver, ...)
    Expands to __pragma(...) when compiling with MSVC and _MSC_VER < ver.
    #define MUU_PUSH_WARNINGS
    Pushes the current compiler warning state onto the stack.
    #define MUU_TRIVIAL_ABI
    Marks a simple type which might otherwise be considered non-trivial as being trivial over ABI boundaries.
    #define MUU_UNIX
    1 when building for a GNU/Unix variant, otherwise 0.
    #define MUU_UNLIKELY(...)
    Expands a conditional to include an optimizer intrinsic (or C++20's [[unlikely]], if available) indicating that an if/else conditional is the unlikely path.
    #define MUU_UNREACHABLE
    Marks a position in the code as being unreachable.
    #define MUU_UNUSED(...)
    Explicitly denotes the result of an expression as being unused.
    #define MUU_VECTORCALL
    Expands to __vectorcall on compilers that support it.
    #define MUU_WINDOWS
    1 when building for the Windows operating system, otherwise 0.

    Define documentation

    #define MUU_ABSTRACT_INTERFACE

    Marks a class being interface-only and not requiring a vtable.

    Useful for abstract base classes:

    class MUU_ABSTRACT_INTERFACE virtual_base
    {
        virtual void fooify() noexcept = 0;
        virtual ~virtual_base() noexcept = default;
    };

    #define MUU_ALWAYS_INLINE

    The same linkage semantics as the inline keyword, with an additional hint to the optimizer that you'd really, really like a function inlined.

    MUU_ALWAYS_INLINE
    void always_inline_me() noexcept
    {
        // ...
    }

    #define MUU_ARCH_AMD64

    1 when targeting AMD64, otherwise 0.

    #define MUU_ARCH_ARM

    1 when targeting any flavour of ARM, otherwise 0.

    #define MUU_ARCH_ARM32

    1 when targeting 32-bit ARM, otherwise 0.

    #define MUU_ARCH_ARM64

    1 when targeting 64-bit ARM, otherwise 0.

    #define MUU_ARCH_BITNESS

    The 'bitness' of the target architecture (e.g. 64 on AMD64).

    #define MUU_ARCH_ITANIUM

    1 when targeting 64-bit Itanium, otherwise 0.

    #define MUU_ARCH_X64

    1 when targeting any 64-bit architecture, otherwise 0.

    #define MUU_ARCH_X86

    1 when targeting 32-bit x86, otherwise 0.

    #define MUU_ASSUME(expr)

    Optimizer hint for signalling various assumptions about state at specific points in code.

    void do_the_thing(int flags) noexcept
    {
        MUU_ASSUME(flags > 0);
        // ... do some some performance-critical code stuff that assumes flags is > 0 here ...
    }

    #define MUU_ATTR(...)

    Expands to __attribute__(( ... )) when compiling with a compiler that supports GNU-style attributes.

    #define MUU_ATTR_CLANG(...)

    Expands to __attribute__(( ... )) when compiling with Clang.

    #define MUU_ATTR_CLANG_GE(ver, ...)

    Expands to __attribute__(( ... )) when compiling with Clang and __clang_major__ >= ver.

    #define MUU_ATTR_CLANG_LT(ver, ...)

    Expands to __attribute__(( ... )) when compiling with Clang and __clang_major__ < ver.

    #define MUU_ATTR_GCC(...)

    Expands to __attribute__(( ... )) when compiling with GCC.

    #define MUU_ATTR_GCC_GE(ver, ...)

    Expands to __attribute__(( ... )) when compiling with GCC and __GNUC__ >= ver.

    #define MUU_ATTR_GCC_LT(ver, ...)

    Expands to __attribute__(( ... )) when compiling with GCC and __GNUC__ < ver.

    #define MUU_ATTR_NDEBUG(...)

    Expands to __attribute__(( ... )) when compiling with a compiler that supports GNU-style attributes and NDEBUG is defined.

    #define MUU_BIG_ENDIAN

    1 when the target environment is big-endian, otherwise 0.

    #define MUU_CLANG

    The value of __clang_major__ when the code is being compiled by LLVM/Clang, otherwise 0.

    #define MUU_CONCAT(x, y)

    Concatenates two preprocessor inputs. Equivalent to the ## operator, but with macro expansion.

    #define MUU_CONSTEVAL

    Expands to C++20's consteval if supported by your compiler, otherwise constexpr.

    #define MUU_CPP

    The currently-targeted C++ standard. 17 for C++17, 20 for C++20, etc.

    #define MUU_CUDA

    1 when compiled with nVIDIA's CUDA compiler, otherwise 0.

    #define MUU_DECLSPEC(...)

    Expands to __declspec( ... ) when compiling with MSVC (or another compiler in MSVC-mode).

    #define MUU_DEFAULT_COPY(T)

    Explicitly defaults the copy constructor and copy-assignment operator of a class or struct.

    class copyable_type
    {
        copyable_type() {}
        MUU_DEFAULT_COPY(copyable_type);
    };
    
    //equivalent to:
    class copyable_type
    {
        copyable_type() {}
    
        copyable_type(const copyable_type&) = default;
        copyable_type& operator=(const copyable_type&) = default;
    };

    #define MUU_DEFAULT_MOVE(T)

    Explicitly defaults the move constructor and move-assignment operator of a class or struct.

    class movable_type
    {
        movable_type() {}
    
        MUU_DEFAULT_MOVE(movable_type);
    };
    
    //equivalent to:
    class movable_type
    {
        movable_type() {}
    
        movable_type(movable_type&&) = default;
        movable_type& operator=(movable_type&&) = default;
    };

    #define MUU_DELETE_COPY(T)

    Explicitly deletes the copy constructor and copy-assignment operator of a class or struct.

    class uncopyable
    {
        uncopyable() {}
        MUU_DELETE_COPY(uncopyable);
    };
    
    //equivalent to:
    class uncopyable
    {
        uncopyable() {}
    
        uncopyable(const uncopyable&) = delete;
        uncopyable& operator=(const uncopyable&) = delete;
    };

    #define MUU_DELETE_MOVE(T)

    Explicitly deletes the move constructor and move-assignment operator of a class or struct.

    class immovable_type
    {
        immovable_type() {}
    
        MUU_DELETE_MOVE(immovable_type);
    };
    
    //equivalent to:
    class immovable_type
    {
        immovable_type() {}
    
        immovable_type(immovable_type&&) = delete;
        immovable_type& operator=(immovable_type&&) = delete;
    };

    #define MUU_DISABLE_ARITHMETIC_WARNINGS

    Disables compiler warnings relating to integer and floating-point arithmetic.

    #define MUU_DISABLE_CODE_ANALYSIS_WARNINGS

    Disables interactive code analysis warnings (e.g. Visual Studio's background analysis engine).

    #define MUU_DISABLE_DEPRECATION_WARNINGS

    Disables compiler warnings relating to deprecated functions, types, etc.

    #define MUU_DISABLE_LIFETIME_WARNINGS

    Disables compiler warnings relating to object lifetime (initialization, destruction, magic statics, et cetera).

    #define MUU_DISABLE_SHADOW_WARNINGS

    Disables compiler warnings relating to variable, class and function name shadowing.

    #define MUU_DISABLE_SPAM_WARNINGS

    Disables compiler warnings that are generally spammy/superfluous (padding, double promotion, cast alignment, etc.)

    #define MUU_DISABLE_SUGGESTION_WARNINGS

    Disables compiler warnings resulting from -Wsuggest=... and friends.

    #define MUU_DISABLE_SWITCH_WARNINGS

    Disables compiler warnings relating to the use of switch statements.

    #define MUU_DISABLE_WARNINGS

    Pushes the current compiler warning state onto the stack then disables ALL compiler warnings.

    #define MUU_DOXYGEN

    1 when the code being interpreted by Doygen or some other documentation generator, otherwise 0.

    #define MUU_EMPTY_BASES

    Marks a class as having only empty base classes.

    This is required for some compilers to use Empty Base Class Optimization:

    class empty_parent
    {
        using value_type = int;
    };
    
    class MUU_EMPTY_BASES nonempty_child : empty_parent
    {
        using empty_parent::value_type;
    
        value_type value;
    };
    
    static_assert(sizeof(nonempty_child) == sizeof(nonempty_child::value_type));

    #define MUU_ENABLE_WARNINGS

    Re-enables compiler warnings again after using MUU_DISABLE_WARNINGS.

    #define MUU_GCC

    The value of __GNUC__ when the code is being compiled by GCC specifically, otherwise 0.

    #define MUU_GCC_LIKE

    The value of __GNUC__ when it is defined by the compiler, otherwise 0.

    #define MUU_HAS_ATTR(attr)

    The result of __has_attribute(attr) if supported by the compiler, otherwise 0.

    #define MUU_HAS_BUILTIN(name)

    The result of __has_builtin(name) if supported by the compiler, otherwise 0.

    #define MUU_HAS_CHAR8

    1 when the compiler supports C++20's char8_t, otherwise 0.

    #define MUU_HAS_CONSTEVAL

    1 when the compiler supports C++20's consteval immediate functions, otherwise 0.

    #define MUU_HAS_CPP_ATTR(attr)

    The result of __has_cpp_attribute(attr) if supported by the compiler, otherwise 0.

    #define MUU_HAS_EXCEPTIONS

    1 when C++ exceptions are supported and enabled, otherwise 0.

    #define MUU_HAS_FEATURE(name)

    The result of __has_feature(name) if supported by the compiler, otherwise 0.

    #define MUU_HAS_FIXED_STRING_LITERALS

    Indicates whether muu::fixed_string string literals (e.g. "hello"_fs) are supported by the compiler.

    #define MUU_HAS_FLOAT128

    1 when the target environment has 128-bit floats, otherwise 0.

    #define MUU_HAS_FLOAT16

    1 when the target environment has the 16-bit floating point type _Float16.

    #define MUU_HAS_FP16

    1 when the target environment has the storage-only 16-bit floating point type __fp16.

    #define MUU_HAS_IF_CONSTEVAL

    1 when the compiler supports C++23's if consteval { }, otherwise 0.

    #define MUU_HAS_INCLUDE(header)

    The result of __has_include(header) if supported by the compiler, otherwise 0.

    #define MUU_HAS_INT128

    1 when the target environment has 128-bit integers, otherwise 0.

    #define MUU_HAS_RTTI

    1 when C++ run-time type identification (RTTI) is supported and enabled, otherwise 0.

    #define MUU_ICC

    The value of __INTEL_COMPILER when the code is being compiled by ICC, otherwise 0.

    #define MUU_IF_CONSTEVAL

    Begins an if consteval block if supported, otherwise falls back on muu::is_constant_evaluated().

    MUU_IF_CONSTEVAL
    {
        this_code_runs_at_compile_time();
    }
    else
    {
        this_code_runs_at_runtime();
    }

    #define MUU_IF_RUNTIME

    Begins an if !consteval block if supported, otherwise falls back on muu::is_constant_evaluated().

    MUU_IF_RUNTIME
    {
        this_code_runs_at_runtime();
    }
    else
    {
        this_code_runs_at_compile_time();
    }

    #define MUU_INTELLISENSE

    1 when the code being compiled by an IDE's 'intellisense' compiler, otherwise 0.

    #define MUU_ISET_AVX

    1 when the target supports the AVX instruction set, otherwise 0.

    #define MUU_ISET_AVX2

    1 when the target supports the AVX2 instruction set, otherwise 0.

    #define MUU_ISET_AVX512

    1 when the target supports any of the AVX512 instruction sets, otherwise 0.

    #define MUU_ISET_MMX

    1 when the target supports the MMX instruction set, otherwise 0.

    #define MUU_ISET_SSE

    1 when the target supports the SSE instruction set, otherwise 0.

    #define MUU_ISET_SSE2

    1 when the target supports the SSE2 instruction set, otherwise 0.

    #define MUU_LIKELY(...)

    Expands a conditional to include an optimizer intrinsic (or C++20's [

  • ], if available) indicating that an if/else conditional is the likely path.
  • if MUU_LIKELY(condition_that_is_almost_always_true)
    {
        do_the_thing();
    }

    #define MUU_LINUX

    1 when building for a Linux distro, otherwise 0.

    #define MUU_LITTLE_ENDIAN

    1 when the target environment is little-endian, otherwise 0.

    #define MUU_MAKE_FLAGS(T)

    Stamps out operators for enum 'flags' types.

    enum class my_flags : unsigned
    {
        none   = 0,
        alpha  = 1,
        beta   = 2,
        gamma  = 4
    };
    MUU_MAKE_FLAGS(my_flags);
    
    // emits these operators:
    constexpr my_flags  operator &  (my_flags,  my_flags) noexcept;
    constexpr my_flags& operator &= (my_flags&, my_flags) noexcept;
    constexpr my_flags  operator |  (my_flags,  my_flags) noexcept;
    constexpr my_flags& operator |= (my_flags&, my_flags) noexcept;
    constexpr my_flags  operator ^  (my_flags,  my_flags) noexcept;
    constexpr my_flags& operator ^= (my_flags&, my_flags) noexcept;
    constexpr my_flags  operator ~  (my_flags) noexcept;
    constexpr bool      operator !  (my_flags) noexcept;

    #define MUU_MAKE_RAW_STRING(s)

    Stringifies the input, converting it verbatim into a raw string literal.

    // these are equivalent:
    constexpr auto str1 = MUU_MAKE_RAW_STRING("It's trap!" the admiral cried.);
    constexpr auto str2 = R"("It's trap!" the admiral cried.)";

    #define MUU_MAKE_STRING(s)

    Stringifies the input, converting it into a string literal.

    // these are equivalent:
    constexpr auto str1 = MUU_MAKE_STRING(Oh noes!);
    constexpr auto str2 = "Oh noes!";

    #define MUU_MAKE_STRING_VIEW(s)

    Stringifies the input, converting it verbatim into a raw string view literal.

    // these are equivalent:
    constexpr std::string_view str1 = MUU_MAKE_STRING_VIEW("It's trap!" the admiral cried.);
    constexpr std::string_view str2 = R"("It's trap!" the admiral cried.)"sv;

    #define MUU_MALLOC

    Optimizer hint that marks an allocating function's pointer return value as representing a newly allocated memory region free from aliasing.

    #define MUU_MSVC

    The value of _MSC_VER when the code is being compiled by MSVC specifically, otherwise 0.

    #define MUU_MSVC_LIKE

    The value of _MSC_VER when it is defined by the compiler, otherwise 0.

    #define MUU_NEVER_INLINE

    A strong hint to the optimizer that you really, really do not want a function inlined.

    MUU_NEVER_INLINE
    int never_inline_me() noexcept
    {
        // ...
    }

    #define MUU_NODISCARD

    Expands to [[nodiscard]] or __attribute__((warn_unused_result)).

    #define MUU_NODISCARD_CTOR

    Expands to [[nodiscard]] if your compiler supports it on constructors.

    This is useful for RAII helper types like locks:

    class raii_lock
    {
        MUU_NODISCARD_CTOR
        raii_lock() noexcept
        {
            super_special_global_lock();
        }
    
        ~raii_lock() noexcept
        {
            super_special_global_unlock();
        }
    };
    
    int whoops() noexcept
    {
        raii_lock{}; // oh noes! forgot to give a name; would be destroyed immediately.
                     // MUU_NODISCARD_CTOR makes the compiler emit a warning here.
    
        something_that_requires_the_lock();
    }

    #define MUU_NOOP

    Expands to a no-op expression.

    #define MUU_NO_UNIQUE_ADDRESS

    Expands to C++20's [[no_unique_address]] if supported by your compiler.

    #define MUU_PAUSE()
    #include <muu/pause.h>

    Expands to a platform-specific intrinsic for pausing/yielding the CPU (e.g. _mm_pause()).

    #define MUU_POP_WARNINGS

    Pops the current compiler warning state off the stack.

    #define MUU_PRAGMA_CLANG(...)

    Expands to _Pragma("clang ...") when compiling with Clang.

    #define MUU_PRAGMA_CLANG_GE(ver, ...)

    Expands to _Pragma("clang ...") when compiling with Clang and __clang_major__ >= ver.

    #define MUU_PRAGMA_CLANG_LT(ver, ...)

    Expands to _Pragma("clang ...") when compiling with Clang and __clang_major__ < ver.

    #define MUU_PRAGMA_GCC(...)

    Expands to _Pragma("GCC ...") when compiling with GCC.

    #define MUU_PRAGMA_GCC_GE(ver, ...)

    Expands to _Pragma("GCC ...") when compiling with GCC and __GNUC__ >= ver.

    #define MUU_PRAGMA_GCC_LT(ver, ...)

    Expands to _Pragma("GCC ...") when compiling with GCC and __GNUC__ < ver.

    #define MUU_PRAGMA_ICC(...)

    Expands to _pragma(...) when compiling with ICC.

    #define MUU_PRAGMA_MSVC(...)

    Expands to __pragma(...) when compiling with MSVC.

    #define MUU_PRAGMA_MSVC_GE(ver, ...)

    Expands to __pragma(...) when compiling with MSVC and _MSC_VER >= ver.

    #define MUU_PRAGMA_MSVC_LT(ver, ...)

    Expands to __pragma(...) when compiling with MSVC and _MSC_VER < ver.

    #define MUU_PUSH_WARNINGS

    Pushes the current compiler warning state onto the stack.

    Use this in tandem with the other warning macros to demarcate regions of code that should have different warning semantics, e.g.:

    MUU_PUSH_WARNINGS;
    MUU_DISABLE_SWITCH_WARNINGS;
    
    int do_the_thing(my_enum val) noexcept
    {
        switch (val)
        {
            case my_enum::one: return 1;
            case my_enum::two: return 2;
            //case my_enum::three: return 3;
        }
        return 0;
    }
    
    MUU_POP_WARNINGS;

    #define MUU_TRIVIAL_ABI

    Marks a simple type which might otherwise be considered non-trivial as being trivial over ABI boundaries.

    This is useful for simple wrappers and 'strong typedef' types, e.g.:

    template <typename T>
    struct MUU_TRIVIAL_ABI strong_typedef
    {
        T value;
        ~strong_typedef() noexcept
        {
            // non-trivial for some reason, maybe debug checks
        }
    }

    #define MUU_UNIX

    1 when building for a GNU/Unix variant, otherwise 0.

    #define MUU_UNLIKELY(...)

    Expands a conditional to include an optimizer intrinsic (or C++20's [[unlikely]], if available) indicating that an if/else conditional is the unlikely path.

    if MUU_UNLIKELY(condition_that_is_almost_always_false)
    {
        do_the_thing();
    }

    #define MUU_UNREACHABLE

    Marks a position in the code as being unreachable.

    #define MUU_UNUSED(...)

    Explicitly denotes the result of an expression as being unused.

    #define MUU_VECTORCALL

    Expands to __vectorcall on compilers that support it.

    #define MUU_WINDOWS

    1 when building for the Windows operating system, otherwise 0.