Skip to content

Commit c5c1dfb

Browse files
authored
Merge pull request #32 from Eczbek/patch-2
macro cleanup
2 parents 22134a7 + 7780135 commit c5c1dfb

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

include/rsl/_impl/macro/compat.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
#include <meta>
3+
4+
#include "compiler.hpp"
5+
6+
#if RSL_COMPILER == RSL_COMPILER_GCC
7+
# define RSL_DEFINE_STATIC_ARRAY(...) [:::std::meta::reflect_constant_array(__VA_ARGS__):]
8+
#else
9+
# define RSL_DEFINE_STATIC_ARRAY(...) (::std::define_static_array(__VA_ARGS__))
10+
#endif

include/rsl/_impl/macro/compiler.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
2-
#include <version>
32

43
#define RSL_COMPILER_UNKNOWN 0
54
#define RSL_COMPILER_CLANG 1
@@ -49,4 +48,4 @@
4948
#else
5049
# define RSL_STDLIB RSL_STDLIB_UNKNOWN
5150
# define RSL_STDLIB_VERSION 0
52-
#endif
51+
#endif

include/rsl/macro

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,40 @@
33
#include <rsl/_impl/macro/compiler.hpp>
44
#include <rsl/_impl/macro/opt.hpp>
55
#include <rsl/_impl/macro/os.hpp>
6+
#include <rsl/_impl/macro/compat.hpp>
67
#include <rsl/_impl/macro/loop.hpp>
78
#include <rsl/_impl/macro/diagnostic.hpp>
89

910
// compile environment checks
1011

1112
/**
12-
* @param compiler: one of UNKNOWN, CLANG, GCC, MSVC
13+
* @param compiler one of UNKNOWN, CLANG, GCC, MSVC
1314
*/
1415
#define $compiler_is(compiler) (RSL_COMPILER == RSL_COMPILER_##compiler)
1516

1617
/**
17-
* @param stdlib: one of UNKNOWN, LIBCXX, GLIBCXX, MSVC
18+
* @param stdlib one of UNKNOWN, LIBCXX, GLIBCXX, MSVC
1819
*/
1920
#define $stdlib_is(stdlib) (RSL_STDLIB == RSL_STDLIB_##stdlib)
2021

2122
/**
22-
* @param os: one of UNKNOWN, WINDOWS, LINUX, MAC, FREEBSD, ANDROID, IOS
23+
* @param os one of UNKNOWN, WINDOWS, LINUX, MAC, FREEBSD, ANDROID, IOS
2324
*/
2425
#define $os_is(os) (RSL_OS == RSL_OS_##os)
2526

26-
/// feature macro helper
27+
/// Feature macro helper
2728
#define $uses_opt(x) USES_OPT(x)
2829

2930
/**
30-
* @param: one of always, never
31+
* @param opt one of always, never
3132
*/
32-
#define $inline(...) RSL_INLINE(__VA_ARGS__)
33+
#define $inline(opt) RSL_INLINE(opt)
3334

34-
/** Enable this overload if expr evaluates to true. Clang only.
35-
* @param expr
36-
*/
35+
/// Enable this overload if a given expression evaluates to true. Clang only.
3736
#define $enable_if(...) RSL_ENABLE_IF(__VA_ARGS__)
3837

3938
//! Workaround for expansion statements in GCC
40-
#if $compiler_is(GCC)
41-
# define $define_static_array(...) [:std::meta::reflect_constant_array(__VA_ARGS__):]
42-
#else
43-
# define $define_static_array(...) std::define_static_array(__VA_ARGS__)
44-
#endif
39+
#define $define_static_array(...) RSL_DEFINE_STATIC_ARRAY(__VA_ARGS__)
4540

4641
/** Applies `macro` to every element and inserts delimiters produced by `delim` between elements
4742
* @param macro function-like macro applied to every element
@@ -62,6 +57,10 @@
6257
*/
6358
#define $for_each(macro, ...) RSL_IMPL_FOR_EACH_DELIM(macro, RSL_IMPL_DELIM_NONE, __VA_ARGS__)
6459

60+
/**
61+
* @param op one of push, pop, disable, error
62+
* @param ... optional arguments
63+
*/
6564
#define $diagnostics(op, ...) RSL_DIAG_##op (__VA_ARGS__)
6665

6766
/// Introduces an explicit template region

0 commit comments

Comments
 (0)