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
17// If the compiler supports `requires`, expands to `requires(...)`. Otherwise to nothing.
18// This is primarily useful for code that must be usable in Cuda, since everywhere else we're free to use C++20 and newer.
19// While Clang 14 technically supports `requires`, we're getting a few weird issues with it (make a nested aggregate class,
20// in the enclosing class make a `MR::Vector` of it, observe that `std::default_initializable` gets baked as `false` on it,
21// disabling some member functions such as `.resize()`).
22#if __cpp_concepts && __has_include(<concepts>) && !(defined(__clang__) && __clang_major__ <= 14) && !(defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 12)
23# define MR_REQUIRES_IF_SUPPORTED(...) requires(__VA_ARGS__)
24# define MR_HAS_REQUIRES 1
25#else
26# define MR_REQUIRES_IF_SUPPORTED(...)
27# define MR_HAS_REQUIRES 0
28#endif