2
0
mirror of https://github.com/boostorg/compat.git synced 2026-01-19 04:02:16 +00:00

Extract nontype_t to its own header; add nontype

This commit is contained in:
Peter Dimov
2025-11-01 17:07:54 +02:00
parent a5a56ee5c0
commit f897f32064
2 changed files with 38 additions and 13 deletions

View File

@@ -5,31 +5,19 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/nontype.hpp>
#include <boost/compat/invoke.hpp>
#include <boost/compat/type_traits.hpp>
#include <type_traits>
#include <utility>
#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 <class... S>
struct function_ref;
#if defined(BOOST_COMPAT_HAS_AUTO_NTTP)
template <auto V>
struct nontype_t {
explicit nontype_t() = default;
};
#endif
namespace detail {
template <bool NoEx>

View File

@@ -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 <boost/config.hpp>
#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 <auto V>
struct nontype_t {
explicit nontype_t() = default;
};
# if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304L
template<auto V>
BOOST_INLINE_CONSTEXPR nontype_t<V> nontype {};
# endif
#endif
} // namespace compat
} // namespace boost
#endif // BOOST_COMPAT_NONTYPE_HPP_INCLUDED