Give constexpr macro a better name

- Put it in the version.hpp properly
- Change its spelling and usage
This commit is contained in:
ThePhD 2021-02-14 00:33:09 -05:00
parent 4e2ee29b34
commit 37d891fa40
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
5 changed files with 52 additions and 30 deletions

View File

@ -29,18 +29,11 @@
#include <sol/traits.hpp> #include <sol/traits.hpp>
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr
#define COULD_BE_CONSTEXPR constexpr
#else
#define COULD_BE_CONSTEXPR const
#endif // BOOST_VERSION
#else #else
#include <sol/optional_implementation.hpp> #include <sol/optional_implementation.hpp>
#endif // Boost vs. Better optional #endif // Boost vs. Better optional
#include <optional> #include <optional>
namespace sol { namespace sol {
@ -49,7 +42,7 @@ namespace sol {
template <typename T> template <typename T>
using optional = boost::optional<T>; using optional = boost::optional<T>;
using nullopt_t = boost::none_t; using nullopt_t = boost::none_t;
COULD_BE_CONSTEXPR nullopt_t nullopt = boost::none; SOL_BOOST_NONE_CONSTEXPR_I_ nullopt_t nullopt = boost::none;
#endif // Boost vs. Better optional #endif // Boost vs. Better optional
namespace meta { namespace meta {
@ -69,13 +62,13 @@ namespace sol {
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
template <typename T> template <typename T>
struct associated_nullopt<boost::optional<T>> { struct associated_nullopt<boost::optional<T>> {
inline static COULD_BE_CONSTEXPR boost::none_t value = boost::none; inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none;
}; };
#endif // Boost nullopt #endif // Boost nullopt
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
template <typename T> template <typename T>
inline COULD_BE_CONSTEXPR auto associated_nullopt_v = associated_nullopt<T>::value; inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt<T>::value;
#else #else
template <typename T> template <typename T>
inline constexpr auto associated_nullopt_v = associated_nullopt<T>::value; inline constexpr auto associated_nullopt_v = associated_nullopt<T>::value;
@ -84,7 +77,7 @@ namespace sol {
} // namespace sol } // namespace sol
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
#undef COULD_BE_CONSTEXPR #undef SOL_BOOST_NONE_CONSTEXPR_I_
#endif #endif
#endif // SOL_OPTIONAL_HPP #endif // SOL_OPTIONAL_HPP

View File

@ -677,6 +677,19 @@
#define SOL_CHAR8_T_I_ SOL_DEFAULT_OFF #define SOL_CHAR8_T_I_ SOL_DEFAULT_OFF
#endif #endif
#endif #endif
#if SOL_IS_ON (SOL_USE_BOOST_I)
#include <boost/version.hpp>
#if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr
#define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
#else
#define SOL_BOOST_NONE_CONSTEXPR_I_ const
#endif // BOOST_VERSION
#else
// assume boost isn't using a garbage version
#define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
#endif
// clang-format on // clang-format on
#endif // SOL_VERSION_HPP #endif // SOL_VERSION_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2021-02-14 05:27:32.027278 UTC // Generated 2021-02-14 05:32:40.818169 UTC
// This header was generated with sol v3.2.3 (revision 810c96b9) // This header was generated with sol v3.2.3 (revision 4e2ee29b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_CONFIG_HPP #ifndef SOL_SINGLE_CONFIG_HPP

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2021-02-14 05:27:32.022278 UTC // Generated 2021-02-14 05:32:40.813170 UTC
// This header was generated with sol v3.2.3 (revision 810c96b9) // This header was generated with sol v3.2.3 (revision 4e2ee29b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
@ -684,6 +684,18 @@
#endif #endif
#endif #endif
#if SOL_IS_ON (SOL_USE_BOOST_I)
#include <boost/version.hpp>
#if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr
#define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
#else
#define SOL_BOOST_NONE_CONSTEXPR_I_ const
#endif // BOOST_VERSION
#else
// assume boost isn't using a garbage version
#define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
#endif
// end of sol/version.hpp // end of sol/version.hpp
#include <utility> #include <utility>

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2021-02-14 05:27:31.429278 UTC // Generated 2021-02-14 05:32:40.369159 UTC
// This header was generated with sol v3.2.3 (revision 810c96b9) // This header was generated with sol v3.2.3 (revision 4e2ee29b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -684,6 +684,18 @@
#endif #endif
#endif #endif
#if SOL_IS_ON (SOL_USE_BOOST_I)
#include <boost/version.hpp>
#if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr
#define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
#else
#define SOL_BOOST_NONE_CONSTEXPR_I_ const
#endif // BOOST_VERSION
#else
// assume boost isn't using a garbage version
#define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
#endif
// end of sol/version.hpp // end of sol/version.hpp
#if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_) #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE_I_)
@ -4131,14 +4143,6 @@ namespace sol {
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr
#define COULD_BE_CONSTEXPR constexpr
#else
#define COULD_BE_CONSTEXPR const
#endif // BOOST_VERSION
#else #else
// beginning of sol/optional_implementation.hpp // beginning of sol/optional_implementation.hpp
@ -6381,7 +6385,7 @@ namespace sol {
template <typename T> template <typename T>
using optional = boost::optional<T>; using optional = boost::optional<T>;
using nullopt_t = boost::none_t; using nullopt_t = boost::none_t;
COULD_BE_CONSTEXPR nullopt_t nullopt = boost::none; SOL_BOOST_NONE_CONSTEXPR_I_ nullopt_t nullopt = boost::none;
#endif // Boost vs. Better optional #endif // Boost vs. Better optional
namespace meta { namespace meta {
@ -6401,13 +6405,13 @@ namespace sol {
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
template <typename T> template <typename T>
struct associated_nullopt<boost::optional<T>> { struct associated_nullopt<boost::optional<T>> {
inline static COULD_BE_CONSTEXPR boost::none_t value = boost::none; inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none;
}; };
#endif // Boost nullopt #endif // Boost nullopt
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
template <typename T> template <typename T>
inline COULD_BE_CONSTEXPR auto associated_nullopt_v = associated_nullopt<T>::value; inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt<T>::value;
#else #else
template <typename T> template <typename T>
inline constexpr auto associated_nullopt_v = associated_nullopt<T>::value; inline constexpr auto associated_nullopt_v = associated_nullopt<T>::value;
@ -6416,7 +6420,7 @@ namespace sol {
} // namespace sol } // namespace sol
#if SOL_IS_ON(SOL_USE_BOOST_I_) #if SOL_IS_ON(SOL_USE_BOOST_I_)
#undef COULD_BE_CONSTEXPR #undef SOL_BOOST_NONE_CONSTEXPR_I_
#endif #endif
// end of sol/optional.hpp // end of sol/optional.hpp