Skip to content

Commit

Permalink
Replace #pragma warning suppression by in-body initialization (#74, t…
Browse files Browse the repository at this point in the history
…hanks @Pesa)

In affected cases, constexpress-ness changes from C++11 to C++14.
Reason: using #pragma to suppress -Winit-list-lifetime does not work in pre-compiled headers.

Was:

#if span_COMPILER_GNUC_VERSION >= 900
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Winit-list-lifetime"
#endif
  • Loading branch information
martinmoene committed Feb 5, 2022
1 parent 2962cb9 commit 8f7935f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions include/nonstd/span.hpp
Expand Up @@ -1068,40 +1068,42 @@ class span

#if !span_BETWEEN( span_COMPILER_MSVC_VERSION, 120, 130 )

#if span_COMPILER_GNUC_VERSION >= 900
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Winit-list-lifetime"
#endif
template< extent_t U = Extent
span_REQUIRES_T((
U != dynamic_extent
))
>
#if span_COMPILER_GNUC_VERSION >= 900 // prevent GCC's "-Winit-list-lifetime"
span_constexpr14 explicit span( std::initializer_list<value_type> il ) span_noexcept
{
data_ = il.begin();
size_ = il.size();
}
#else
span_constexpr explicit span( std::initializer_list<value_type> il ) span_noexcept
: data_( il.begin() )
, size_( il.size() )
{}
#if span_COMPILER_GNUC_VERSION >= 900
# pragma GCC diagnostic pop
#endif

#endif // MSVC 120 (VS2013)

#if span_COMPILER_GNUC_VERSION >= 900
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Winit-list-lifetime"
#endif
template< extent_t U = Extent
span_REQUIRES_T((
U == dynamic_extent
))
>
#if span_COMPILER_GNUC_VERSION >= 900 // prevent GCC's "-Winit-list-lifetime"
span_constexpr14 /*explicit*/ span( std::initializer_list<value_type> il ) span_noexcept
{
data_ = il.begin();
size_ = il.size();
}
#else
span_constexpr /*explicit*/ span( std::initializer_list<value_type> il ) span_noexcept
: data_( il.begin() )
, size_( il.size() )
{}
#if span_COMPILER_GNUC_VERSION >= 900
# pragma GCC diagnostic pop
#endif

#endif // P2447
Expand Down

0 comments on commit 8f7935f

Please sign in to comment.