From f897f32064b43321abe6d66e169e863bc38cd6bc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 1 Nov 2025 17:07:54 +0200 Subject: [PATCH] Extract nontype_t to its own header; add nontype --- include/boost/compat/function_ref.hpp | 14 +--------- include/boost/compat/nontype.hpp | 37 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 include/boost/compat/nontype.hpp diff --git a/include/boost/compat/function_ref.hpp b/include/boost/compat/function_ref.hpp index 2838ce1..d9d5719 100644 --- a/include/boost/compat/function_ref.hpp +++ b/include/boost/compat/function_ref.hpp @@ -5,31 +5,19 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include #include #include #include #include -#if defined(__cpp_nontype_template_parameter_auto) && __cpp_nontype_template_parameter_auto >= 201606L -#define BOOST_COMPAT_HAS_AUTO_NTTP -#endif - namespace boost { namespace compat { template struct function_ref; -#if defined(BOOST_COMPAT_HAS_AUTO_NTTP) - -template -struct nontype_t { - explicit nontype_t() = default; -}; - -#endif - namespace detail { template diff --git a/include/boost/compat/nontype.hpp b/include/boost/compat/nontype.hpp new file mode 100644 index 0000000..5f05204 --- /dev/null +++ b/include/boost/compat/nontype.hpp @@ -0,0 +1,37 @@ +#ifndef BOOST_COMPAT_NONTYPE_HPP_INCLUDED +#define BOOST_COMPAT_NONTYPE_HPP_INCLUDED + +// Copyright 2024 Christian Mazakas +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include + +#if defined(__cpp_nontype_template_parameter_auto) && __cpp_nontype_template_parameter_auto >= 201606L +#define BOOST_COMPAT_HAS_AUTO_NTTP +#endif + +namespace boost { +namespace compat { + +#if defined(BOOST_COMPAT_HAS_AUTO_NTTP) + +template +struct nontype_t { + explicit nontype_t() = default; +}; + +# if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304L + +template +BOOST_INLINE_CONSTEXPR nontype_t nontype {}; + +# endif + +#endif + +} // namespace compat +} // namespace boost + +#endif // BOOST_COMPAT_NONTYPE_HPP_INCLUDED