MeshLib
Loading...
Searching...
No Matches
MRMacros.h
Go to the documentation of this file.
1#pragma once
2
3// Those are generic helper macros that don't have their own headers.
4
5// Convert to a string.
6#define MR_STR(...) MR_STR_(__VA_ARGS__)
7#define MR_STR_(...) #__VA_ARGS__
8
9// Returns the argument unchanged.
10#define MR_IDENTITY(...) __VA_ARGS__
11
12// A helper for writing preprocessor loops.
13#define MR_END(...) DETAIL_MR_END(__VA_ARGS__)
14#define DETAIL_MR_END(...) __VA_ARGS__##_END
15
16// Concat strings
17#define MR_CONCAT( a, b ) MR_CONCAT_( a, b )
18#define MR_CONCAT_( a, b ) a ## b
19
20// If the compiler supports `requires`, expands to `requires(...)`. Otherwise to nothing.
21// This is primarily useful for code that must be usable in Cuda, since everywhere else we're free to use C++20 and newer.
22// While Clang 14 technically supports `requires`, we're getting a few weird issues with it (make a nested aggregate class,
23// in the enclosing class make a `MR::Vector` of it, observe that `std::default_initializable` gets baked as `false` on it,
24// disabling some member functions such as `.resize()`).
25#if __cpp_concepts && __has_include(<concepts>) && !(defined(__clang__) && __clang_major__ <= 14) && !(defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 12)
26# define MR_REQUIRES_IF_SUPPORTED(...) requires(__VA_ARGS__)
27# define MR_HAS_REQUIRES 1
28#else
29# define MR_REQUIRES_IF_SUPPORTED(...)
30# define MR_HAS_REQUIRES 0
31#endif
32
33
34#ifdef _MSC_VER
35#define MR_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] // The unprefixed version has no effect on MSVC.
36#else
37#define MR_NO_UNIQUE_ADDRESS [[no_unique_address]]
38#endif