Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate apple-clang deprecation warnings about redeclared constexpr class static members #1834

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/concepts/swap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#endif

#ifndef CPP_CXX_INLINE_VARIABLES
#ifdef __cpp_inline_variables // TODO: fix this if SD-6 picks another name
#ifdef __cpp_inline_variables
#define CPP_CXX_INLINE_VARIABLES __cpp_inline_variables
// TODO: remove once clang defines __cpp_inline_variables (or equivalent)
#elif defined(__clang__) && \
Expand Down Expand Up @@ -124,8 +124,11 @@ namespace concepts
{
static constexpr T const value {};
};

#if CPP_CXX_INLINE_VARIABLES < 201606L
template<typename T>
constexpr T const static_const<T>::value;
#endif
}
/// \endcond

Expand Down
12 changes: 7 additions & 5 deletions include/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2835,12 +2835,14 @@ namespace meta
template <typename T>
struct static_const
{
static constexpr T value{};
static constexpr T const value{};
};

#if !META_CXX_INLINE_VARIABLES
// Avoid potential ODR violations with global objects:
template <typename T>
constexpr T static_const<T>::value;
template<typename T>
constexpr T const static_const<T>::value;
#endif
} // namespace detail

///\endcond
Expand Down Expand Up @@ -3776,9 +3778,9 @@ namespace meta
{
/// A user-defined literal that generates objects of type \c meta::size_t.
/// \ingroup integral
template <char... Chs>
template<char... Chs>
constexpr fold<list<char_<Chs>...>, meta::size_t<0>, quote<detail::atoi_>>
operator"" _z()
operator""_z()
{
return {};
}
Expand Down
135 changes: 83 additions & 52 deletions include/range/v3/iterator/diffmax_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,85 @@ namespace ranges
template<typename Enable>
constexpr bool _is_integer_like_<diffmax_t, Enable> = true;
#endif

template<bool = true>
struct diffmax_numeric_limits
{
static constexpr bool const is_specialized = true;
static constexpr bool const is_signed = true;
static constexpr bool const is_integer = true;
static constexpr bool const is_exact = true;
static constexpr bool const has_infinity = false;
static constexpr bool const has_quiet_NaN = false;
static constexpr bool const has_signaling_NaN = false;
static constexpr bool const has_denorm = false;
static constexpr bool const has_denorm_loss = false;
static constexpr std::float_round_style const round_style =
std::round_toward_zero;
static constexpr bool const is_iec559 = false;
static constexpr bool const is_bounded = true;
static constexpr bool const is_modulo = false;
static constexpr int const digits = CHAR_BIT * sizeof(std::uintmax_t) + 1;
static constexpr int const digits10 =
static_cast<int>(digits * 0.301029996); // digits * std::log10(2)
static constexpr int const max_digits10 = 0;
static constexpr int const radix = 2;
static constexpr int const min_exponent = 0;
static constexpr int const min_exponent10 = 0;
static constexpr int const max_exponent = 0;
static constexpr int const max_exponent10 = 0;
static constexpr bool const traps = true;
static constexpr bool const tinyness_before = false;
};

#if RANGES_CXX_INLINE_VARIABLES < RANGES_CXX_INLINE_VARIABLES_17
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_specialized;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_signed;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_integer;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_exact;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::has_infinity;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::has_quiet_NaN;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::has_signaling_NaN;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::has_denorm;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::has_denorm_loss;
template<bool B>
constexpr std::float_round_style const diffmax_numeric_limits<B>::round_style;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_iec559;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_bounded;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::is_modulo;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::digits;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::digits10;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::max_digits10;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::radix;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::min_exponent;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::min_exponent10;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::max_exponent;
template<bool B>
constexpr int const diffmax_numeric_limits<B>::max_exponent10;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::traps;
template<bool B>
constexpr bool const diffmax_numeric_limits<B>::tinyness_before;
#endif
} // namespace detail
/// \endcond
} // namespace ranges
Expand All @@ -358,32 +437,8 @@ namespace std
{
template<>
struct numeric_limits<::ranges::detail::diffmax_t>
: ::ranges::detail::diffmax_numeric_limits<>
{
static constexpr bool is_specialized = true;
static constexpr bool is_signed = true;
static constexpr bool is_integer = true;
static constexpr bool is_exact = true;
static constexpr bool has_infinity = false;
static constexpr bool has_quiet_NaN = false;
static constexpr bool has_signaling_NaN = false;
static constexpr bool has_denorm = false;
static constexpr bool has_denorm_loss = false;
static constexpr std::float_round_style round_style = std::round_toward_zero;
static constexpr bool is_iec559 = false;
static constexpr bool is_bounded = true;
static constexpr bool is_modulo = false;
static constexpr int digits = CHAR_BIT * sizeof(std::uintmax_t) + 1;
static constexpr int digits10 =
static_cast<int>(digits * 0.301029996); // digits * std::log10(2)
static constexpr int max_digits10 = 0;
static constexpr int radix = 2;
static constexpr int min_exponent = 0;
static constexpr int min_exponent10 = 0;
static constexpr int max_exponent = 0;
static constexpr int max_exponent10 = 0;
static constexpr bool traps = true;
static constexpr bool tinyness_before = false;

static constexpr ::ranges::detail::diffmax_t max() noexcept
{
return std::uintmax_t(-1);
Expand Down Expand Up @@ -421,45 +476,21 @@ namespace std
return 0;
}
};

template<>
struct numeric_limits<::ranges::detail::diffmax_t const>
: numeric_limits<::ranges::detail::diffmax_t>
{};

template<>
struct numeric_limits<::ranges::detail::diffmax_t volatile>
: numeric_limits<::ranges::detail::diffmax_t>
{};

template<>
struct numeric_limits<::ranges::detail::diffmax_t const volatile>
: numeric_limits<::ranges::detail::diffmax_t>
{};

#if RANGES_CXX_INLINE_VARIABLES >= RANGES_CXX_INLINE_VARIABLES_17
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_specialized;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_signed;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_integer;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_exact;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::has_infinity;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::has_quiet_NaN;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::has_signaling_NaN;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::has_denorm;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::has_denorm_loss;
inline constexpr std::float_round_style
numeric_limits<::ranges::detail::diffmax_t>::round_style;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_iec559;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_bounded;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::is_modulo;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::digits;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::digits10;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::max_digits10;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::radix;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::min_exponent;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::min_exponent10;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::max_exponent;
inline constexpr int numeric_limits<::ranges::detail::diffmax_t>::max_exponent10;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::traps;
inline constexpr bool numeric_limits<::ranges::detail::diffmax_t>::tinyness_before;
#endif
} // namespace std
/// \endcond

Expand Down
9 changes: 6 additions & 3 deletions include/range/v3/utility/static_const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@
#ifndef RANGES_V3_UTILITY_STATIC_CONST_HPP
#define RANGES_V3_UTILITY_STATIC_CONST_HPP

#include <range/v3/detail/config.hpp>

namespace ranges
{
/// \ingroup group-utility

template<typename T>
struct static_const
{
static constexpr T value{};
static constexpr T const value{};
};

#if RANGES_CXX_INLINE_VARIABLES < RANGES_CXX_INLINE_VARIABLES_17
/// \ingroup group-utility
/// \sa `static_const`
template<typename T>
constexpr T static_const<T>::value;
constexpr T const static_const<T>::value;
#endif
} // namespace ranges

#endif
2 changes: 2 additions & 0 deletions include/range/v3/view/span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ namespace ranges
template<typename T, detail::span_index_t N>
RANGES_INLINE_VAR constexpr bool enable_borrowed_range<span<T, N>> = true;

#if RANGES_CXX_INLINE_VARIABLES < RANGES_CXX_INLINE_VARIABLES_17
template<typename T, detail::span_index_t N>
constexpr detail::span_index_t span<T, N>::extent;
#endif

#if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17
template(typename Rng)(
Expand Down
Loading