Ruby  3.4.0dev (2024-11-22 revision 37a72b0150ec36b4ea27175039afc28c62207b0c)
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
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 */
Defines RBIMPL_COMPILER_IS.
Defines RBIMPL_HAS_FEATURE.