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

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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
27#if ! defined(__cplusplus)
28# /* Makes no sense. */
29# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 0
30# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 0
31
32#elif defined(__cpp_constexpr)
33# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
34# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cpp_constexpr >= 200704L)
35# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cpp_constexpr >= 201304L)
36
37#elif RBIMPL_COMPILER_SINCE(MSVC, 19, 0, 0)
38# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 00)
39# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 RBIMPL_COMPILER_SINCE(MSVC, 19, 11, 00)
40
41#elif RBIMPL_COMPILER_SINCE(SunPro, 5, 13, 0)
42# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cplusplus >= 201103L)
43# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cplusplus >= 201402L)
44
45#elif RBIMPL_COMPILER_SINCE(GCC, 4, 9, 0)
46# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cplusplus >= 201103L)
47# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cplusplus >= 201402L)
48
49#elif RBIMPL_HAS_FEATURE(cxx_relaxed_constexpr)
50# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 1
51# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 1
52
53#elif RBIMPL_HAS_FEATURE(cxx_constexpr)
54# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 1
55# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 0
56
57#else
58# /* :FIXME: icpc must have constexpr but don't know how to detect. */
59# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 0
60# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 0
61#endif
65#if RBIMPL_HAS_ATTR_CONSTEXPR_CXX14
66# define RBIMPL_ATTR_CONSTEXPR(_) constexpr
67
68#elif RBIMPL_HAS_ATTR_CONSTEXPR_CXX11
69# define RBIMPL_ATTR_CONSTEXPR(_) RBIMPL_ATTR_CONSTEXPR_ ## _
70# define RBIMPL_ATTR_CONSTEXPR_CXX11 constexpr
71# define RBIMPL_ATTR_CONSTEXPR_CXX14 /* void */
72
73#else
74# define RBIMPL_ATTR_CONSTEXPR(_) /* void */
75#endif
76
78#if !RUBY_DEBUG
79# define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_) RBIMPL_ATTR_CONSTEXPR(_)
80#else
81# define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_) /* void */
82#endif
83
84#endif /* RBIMPL_ATTR_CONSTEXPR_H */
compiler_is.h
Defines RBIMPL_COMPILER_IS.
feature.h
Defines RBIMPL_HAS_FEATURE.