Ruby: include/ruby/internal/attr/constexpr.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

constexpr.h
Go to the documentation of this file.
1#ifndef RBIMPL_ATTR_CONSTEXPR_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ATTR_CONSTEXPR_H
23#include "ruby/internal/has/feature.h"
24#include "ruby/internal/compiler_is.h"
25#include "ruby/internal/token_paste.h"
26
28#if ! defined(__cplusplus)
29# /* Makes no sense. */
30# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 0
31# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 0
32
33#elif defined(__cpp_constexpr)
34# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
35# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cpp_constexpr >= 200704L)
36# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cpp_constexpr >= 201304L)
37
38#elif RBIMPL_COMPILER_SINCE(MSVC, 19, 0, 0)
39# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 00)
40# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 RBIMPL_COMPILER_SINCE(MSVC, 19, 11, 00)
41
42#elif RBIMPL_COMPILER_SINCE(SunPro, 5, 13, 0)
43# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cplusplus >= 201103L)
44# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cplusplus >= 201402L)
45
46#elif RBIMPL_COMPILER_SINCE(GCC, 4, 9, 0)
47# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cplusplus >= 201103L)
48# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cplusplus >= 201402L)
49
50#elif RBIMPL_HAS_FEATURE(cxx_relaxed_constexpr)
51# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 1
52# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 1
53
54#elif RBIMPL_HAS_FEATURE(cxx_constexpr)
55# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 1
56# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 0
57
58#else
59# /* :FIXME: icpc must have constexpr but don't know how to detect. */
60# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 0
61# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 0
62#endif
66#if RBIMPL_HAS_ATTR_CONSTEXPR_CXX14
67# define RBIMPL_ATTR_CONSTEXPR(_) constexpr
68
69#elif RBIMPL_HAS_ATTR_CONSTEXPR_CXX11
70# define RBIMPL_ATTR_CONSTEXPR(_) RBIMPL_TOKEN_PASTE(RBIMPL_ATTR_CONSTEXPR_, _)
71# define RBIMPL_ATTR_CONSTEXPR_CXX11 constexpr
72# define RBIMPL_ATTR_CONSTEXPR_CXX14 /* void */
73
74#else
75# define RBIMPL_ATTR_CONSTEXPR(_) /* void */
76#endif
77
79#if !RUBY_DEBUG
80# define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_) RBIMPL_ATTR_CONSTEXPR(_)
81#else
82# define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_) /* void */
83#endif
84
85#endif /* RBIMPL_ATTR_CONSTEXPR_H */
compiler_is.h
Defines RBIMPL_COMPILER_IS.
feature.h
Defines RBIMPL_HAS_FEATURE.
token_paste.h
Defines RBIMPL_TOKEN_PASTE.