Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/rsl/_impl/macro/compat.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once
#include <meta>

#include "compiler.hpp"

#if RSL_COMPILER == RSL_COMPILER_GCC
# define RSL_DEFINE_STATIC_ARRAY(...) [:::std::meta::reflect_constant_array(__VA_ARGS__):]
#else
# define RSL_DEFINE_STATIC_ARRAY(...) (::std::define_static_array(__VA_ARGS__))
#endif
3 changes: 1 addition & 2 deletions include/rsl/_impl/macro/compiler.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include <version>

#define RSL_COMPILER_UNKNOWN 0
#define RSL_COMPILER_CLANG 1
Expand Down Expand Up @@ -49,4 +48,4 @@
#else
# define RSL_STDLIB RSL_STDLIB_UNKNOWN
# define RSL_STDLIB_VERSION 0
#endif
#endif
27 changes: 13 additions & 14 deletions include/rsl/macro
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,40 @@
#include <rsl/_impl/macro/compiler.hpp>
#include <rsl/_impl/macro/opt.hpp>
#include <rsl/_impl/macro/os.hpp>
#include <rsl/_impl/macro/compat.hpp>
#include <rsl/_impl/macro/loop.hpp>
#include <rsl/_impl/macro/diagnostic.hpp>

// compile environment checks

/**
* @param compiler: one of UNKNOWN, CLANG, GCC, MSVC
* @param compiler one of UNKNOWN, CLANG, GCC, MSVC
*/
#define $compiler_is(compiler) (RSL_COMPILER == RSL_COMPILER_##compiler)

/**
* @param stdlib: one of UNKNOWN, LIBCXX, GLIBCXX, MSVC
* @param stdlib one of UNKNOWN, LIBCXX, GLIBCXX, MSVC
*/
#define $stdlib_is(stdlib) (RSL_STDLIB == RSL_STDLIB_##stdlib)

/**
* @param os: one of UNKNOWN, WINDOWS, LINUX, MAC, FREEBSD, ANDROID, IOS
* @param os one of UNKNOWN, WINDOWS, LINUX, MAC, FREEBSD, ANDROID, IOS
*/
#define $os_is(os) (RSL_OS == RSL_OS_##os)

/// feature macro helper
/// Feature macro helper
#define $uses_opt(x) USES_OPT(x)

/**
* @param: one of always, never
* @param opt one of always, never
*/
#define $inline(...) RSL_INLINE(__VA_ARGS__)
#define $inline(opt) RSL_INLINE(opt)

/** Enable this overload if expr evaluates to true. Clang only.
* @param expr
*/
/// Enable this overload if a given expression evaluates to true. Clang only.
#define $enable_if(...) RSL_ENABLE_IF(__VA_ARGS__)

//! Workaround for expansion statements in GCC
#if $compiler_is(GCC)
# define $define_static_array(...) [:std::meta::reflect_constant_array(__VA_ARGS__):]
#else
# define $define_static_array(...) std::define_static_array(__VA_ARGS__)
#endif
#define $define_static_array(...) RSL_DEFINE_STATIC_ARRAY(__VA_ARGS__)

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

/**
* @param op one of push, pop, disable, error
* @param ... optional arguments
*/
#define $diagnostics(op, ...) RSL_DIAG_##op (__VA_ARGS__)

/// Introduces an explicit template region
Expand Down