Kaydet (Commit) 7d928d8c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

HAVE_CXX14_CONSTEXPR is always true now

...but for safety, leave the configure.ac check in for some longer.

o3tl::array_view::max_size (include/o3tl/array_view.hxx) and
o3tl::basic_string_view::max_size (include/o3tl/string_view.hxx) started to
produce loplugin:staticmethods warnings, which I silenced by /not/ making the
functions static.  Those classes are meant to be temporary drop-in replacements
for standard classes (std::span slated for C++20, prev. std::array_view; and
std::basic_string_view, resp.), so should have the same behavior as their
standard counterparts (and making the functions static would likely cause
loplugin:staticaccess warnings at call sites).

Change-Id: If21674dbf02886f453ca447544e37b184df5a25e
Reviewed-on: https://gerrit.libreoffice.org/64768
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 74dd206e
...@@ -12,7 +12,6 @@ Any change in this header will cause a rebuild of almost everything. ...@@ -12,7 +12,6 @@ Any change in this header will cause a rebuild of almost everything.
#ifndef CONFIG_GLOBAL_H #ifndef CONFIG_GLOBAL_H
#define CONFIG_GLOBAL_H #define CONFIG_GLOBAL_H
#define HAVE_CXX14_CONSTEXPR 0
#define HAVE_GCC_BUILTIN_ATOMIC 0 #define HAVE_GCC_BUILTIN_ATOMIC 0
#define HAVE_GCC_BUILTIN_FFS 0 #define HAVE_GCC_BUILTIN_FFS 0
/* _Pragma */ /* _Pragma */
......
...@@ -6347,7 +6347,8 @@ return !(i != 0 && j != 0); ...@@ -6347,7 +6347,8 @@ return !(i != 0 && j != 0);
AC_LANG_POP([C++]) AC_LANG_POP([C++])
CXXFLAGS=$save_CXXFLAGS CXXFLAGS=$save_CXXFLAGS
AC_MSG_CHECKING([whether $CXX supports C++14 constexpr]) dnl This check can eventually be removed completely (e.g., after libreoffice-6-3 branch off):
AC_MSG_CHECKING([that $CXX supports C++14 constexpr])
save_CXXFLAGS=$CXXFLAGS save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11" CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
AC_LANG_PUSH([C++]) AC_LANG_PUSH([C++])
...@@ -6375,13 +6376,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ...@@ -6375,13 +6376,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
} }
}; };
constexpr auto v2 = S{10}.f(); constexpr auto v2 = S{10}.f();
]])], [cxx14_constexpr=yes], [cxx14_constexpr=no]) ]])], AC_MSG_RESULT([yes]), AC_MSG_ERROR([$CXX lacks required C++14 constexpr support]))
AC_LANG_POP([C++]) AC_LANG_POP([C++])
CXXFLAGS=$save_CXXFLAGS CXXFLAGS=$save_CXXFLAGS
AC_MSG_RESULT([$cxx14_constexpr])
if test "$cxx14_constexpr" = yes; then
AC_DEFINE([HAVE_CXX14_CONSTEXPR])
fi
dnl _Pragma support (may require C++11) dnl _Pragma support (may require C++11)
if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
......
...@@ -22,17 +22,10 @@ ...@@ -22,17 +22,10 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include <config_global.h>
#include <rtl/string.hxx> #include <rtl/string.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <sal/types.h> #include <sal/types.h>
#if HAVE_CXX14_CONSTEXPR
#define CONSTEXPR constexpr
#else
#define CONSTEXPR
#endif
namespace o3tl { namespace o3tl {
#if defined _MSC_VER #if defined _MSC_VER
...@@ -64,15 +57,13 @@ public: ...@@ -64,15 +57,13 @@ public:
constexpr array_view() noexcept : data_(nullptr), size_(0) {} constexpr array_view() noexcept : data_(nullptr), size_(0) {}
template<size_type N> template<size_type N>
CONSTEXPR array_view (T (&a)[N]) noexcept : data_(a), size_(N) {} constexpr array_view (T (&a)[N]) noexcept : data_(a), size_(N) {}
CONSTEXPR array_view (T *a, size_type len) noexcept constexpr array_view (T *a, size_type len) noexcept
: data_(a), size_(len) : data_(a), size_(len)
{ {
#if HAVE_CXX14_CONSTEXPR
// not terribly sure about this, might need to relax it // not terribly sure about this, might need to relax it
assert((a == nullptr && len == 0) || (a != nullptr && len > 0)); assert((a == nullptr && len == 0) || (a != nullptr && len > 0));
#endif
} }
/// Allow for assigning array_view<T> to array_view<T const> i.e. /// Allow for assigning array_view<T> to array_view<T const> i.e.
...@@ -106,25 +97,17 @@ public: ...@@ -106,25 +97,17 @@ public:
constexpr size_type size() const noexcept { return size_; } constexpr size_type size() const noexcept { return size_; }
constexpr size_type length() const noexcept { return size(); } constexpr size_type length() const noexcept { return size(); }
#if !defined __clang__ || HAVE_CXX14_CONSTEXPR constexpr size_type max_size() const noexcept {
constexpr (void) this; // silence loplugin:staticmethods
#endif
size_type max_size() const noexcept {
#if defined __clang__ // avoid constexpr issues with other, older compilers
(void) this; // loplugin:staticmethods
#endif
return npos - 1; return npos - 1;
} }
constexpr reference operator [](size_type pos) const { constexpr reference operator [](size_type pos) const {
#if HAVE_CXX14_CONSTEXPR
assert(pos < size()); assert(pos < size());
#endif
return data_[pos]; return data_[pos];
} }
CONSTEXPR constexpr reference at(size_type pos) const {
reference at(size_type pos) const {
if (pos >= size()) { if (pos >= size()) {
throw std::out_of_range("o3tl::array_view::at"); throw std::out_of_range("o3tl::array_view::at");
} }
...@@ -132,22 +115,18 @@ public: ...@@ -132,22 +115,18 @@ public:
} }
constexpr reference front() const { constexpr reference front() const {
#if HAVE_CXX14_CONSTEXPR
assert(!empty()); assert(!empty());
#endif
return operator [](0); return operator [](0);
} }
constexpr reference back() const { constexpr reference back() const {
#if HAVE_CXX14_CONSTEXPR
assert(!empty()); assert(!empty());
#endif
return operator [](size() - 1); return operator [](size() - 1);
} }
constexpr pointer data() const noexcept { return data_; } constexpr pointer data() const noexcept { return data_; }
CONSTEXPR void swap(array_view & s) noexcept { constexpr void swap(array_view & s) noexcept {
std::swap(data_, s.data_); std::swap(data_, s.data_);
std::swap(size_, s.size_); std::swap(size_, s.size_);
} }
...@@ -179,9 +158,6 @@ struct hash<o3tl::array_view<T>> { ...@@ -179,9 +158,6 @@ struct hash<o3tl::array_view<T>> {
} // namespace std } // namespace std
#undef CONSTEXPR
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <config_global.h>
// C++17 std::clamp // C++17 std::clamp
namespace o3tl namespace o3tl
...@@ -29,9 +27,7 @@ using std::clamp; ...@@ -29,9 +27,7 @@ using std::clamp;
template <typename T> constexpr const T& clamp(const T& v, const T& lo, const T& hi) template <typename T> constexpr const T& clamp(const T& v, const T& lo, const T& hi)
{ {
#if HAVE_CXX14_CONSTEXPR
assert(!(hi < lo)); assert(!(hi < lo));
#endif
return v < lo ? lo : (hi < v ? hi : v); return v < lo ? lo : (hi < v ? hi : v);
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
#include <config_global.h>
#include <rtl/string.hxx> #include <rtl/string.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <sal/types.h> #include <sal/types.h>
...@@ -174,10 +173,7 @@ public: ...@@ -174,10 +173,7 @@ public:
constexpr basic_string_view(basic_string_view const &) noexcept = default; constexpr basic_string_view(basic_string_view const &) noexcept = default;
#if HAVE_CXX14_CONSTEXPR constexpr basic_string_view & operator =(basic_string_view const & other) noexcept = default;
constexpr
#endif
basic_string_view & operator =(basic_string_view const & other) noexcept = default;
// The various character types are handled below in the "LO specifics, to // The various character types are handled below in the "LO specifics, to
// make up for traits::length not necessarily being constexpr yet for // make up for traits::length not necessarily being constexpr yet for
...@@ -217,29 +213,19 @@ public: ...@@ -217,29 +213,19 @@ public:
constexpr size_type length() const noexcept { return size(); } constexpr size_type length() const noexcept { return size(); }
#if !defined __clang__ || HAVE_CXX14_CONSTEXPR constexpr size_type max_size() const noexcept {
constexpr (void) this; // silence loplugin:staticmethods
#endif
size_type max_size() const noexcept {
#if defined __clang__ // avoid constexpr issues with other, older compilers
(void) this; // loplugin:staticmethods
#endif
return npos - 1; return npos - 1;
} }
constexpr bool empty() const noexcept { return size_ == 0; } constexpr bool empty() const noexcept { return size_ == 0; }
constexpr const_reference operator [](size_type pos) const { constexpr const_reference operator [](size_type pos) const {
#if HAVE_CXX14_CONSTEXPR
assert(pos < size()); assert(pos < size());
#endif
return data_[pos]; return data_[pos];
} }
#if HAVE_CXX14_CONSTEXPR constexpr const_reference at(size_type pos) const {
constexpr
#endif
const_reference at(size_type pos) const {
if (pos >= size()) { if (pos >= size()) {
throw std::out_of_range("o3tl::basic_string_view::at"); throw std::out_of_range("o3tl::basic_string_view::at");
} }
...@@ -247,42 +233,29 @@ public: ...@@ -247,42 +233,29 @@ public:
} }
constexpr const_reference front() const { constexpr const_reference front() const {
#if HAVE_CXX14_CONSTEXPR
assert(!empty()); assert(!empty());
#endif
return operator [](0); return operator [](0);
} }
constexpr const_reference back() const { constexpr const_reference back() const {
#if HAVE_CXX14_CONSTEXPR
assert(!empty()); assert(!empty());
#endif
return operator [](size() - 1); return operator [](size() - 1);
} }
constexpr const_pointer data() const noexcept { return data_; } constexpr const_pointer data() const noexcept { return data_; }
#if HAVE_CXX14_CONSTEXPR constexpr void remove_prefix(size_type n) {
constexpr
#endif
void remove_prefix(size_type n) {
assert(n <= size()); assert(n <= size());
data_ += n; data_ += n;
size_ -= n; size_ -= n;
} }
#if HAVE_CXX14_CONSTEXPR constexpr void remove_suffix(size_type n) {
constexpr
#endif
void remove_suffix(size_type n) {
assert(n <= size()); assert(n <= size());
size_ -= n; size_ -= n;
} }
#if HAVE_CXX14_CONSTEXPR constexpr void swap(basic_string_view & s) noexcept {
constexpr
#endif
void swap(basic_string_view & s) noexcept {
std::swap(data_, s.data_); std::swap(data_, s.data_);
std::swap(size_, s.size_); std::swap(size_, s.size_);
} }
...@@ -296,10 +269,7 @@ public: ...@@ -296,10 +269,7 @@ public:
return rlen; return rlen;
} }
#if HAVE_CXX14_CONSTEXPR constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const {
constexpr
#endif
basic_string_view substr(size_type pos = 0, size_type n = npos) const {
if (pos > size()) { if (pos > size()) {
throw std::out_of_range("o3tl::basic_string_view::copy"); throw std::out_of_range("o3tl::basic_string_view::copy");
} }
...@@ -307,10 +277,7 @@ public: ...@@ -307,10 +277,7 @@ public:
data() + pos, std::min(n, size_type(size() - pos))); data() + pos, std::min(n, size_type(size() - pos)));
} }
#if HAVE_CXX14_CONSTEXPR constexpr int compare(basic_string_view s) const noexcept {
constexpr
#endif
int compare(basic_string_view s) const noexcept {
auto n = traits::compare(data(), s.data(), std::min(size(), s.size())); auto n = traits::compare(data(), s.data(), std::min(size(), s.size()));
return n == 0 return n == 0
? (size() < s.size() ? -1 : size() == s.size() ? 0 : 1) : n; ? (size() < s.size() ? -1 : size() == s.size() ? 0 : 1) : n;
...@@ -335,10 +302,7 @@ public: ...@@ -335,10 +302,7 @@ public:
size_type pos1, size_type n1, charT const * s, size_type n2) const size_type pos1, size_type n1, charT const * s, size_type n2) const
{ return substr(pos1, n1).compare(basic_string_view(s, n2)); } { return substr(pos1, n1).compare(basic_string_view(s, n2)); }
#if HAVE_CXX14_CONSTEXPR constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept {
constexpr
#endif
size_type find(basic_string_view s, size_type pos = 0) const noexcept {
if (s.size() <= size()) { if (s.size() <= size()) {
for (auto xpos = pos; xpos <= size() - s.size(); ++xpos) { for (auto xpos = pos; xpos <= size() - s.size(); ++xpos) {
bool match = true; bool match = true;
...@@ -365,10 +329,7 @@ public: ...@@ -365,10 +329,7 @@ public:
constexpr size_type find(charT const * s, size_type pos = 0) const constexpr size_type find(charT const * s, size_type pos = 0) const
{ return find(basic_string_view(s), pos); } { return find(basic_string_view(s), pos); }
#if HAVE_CXX14_CONSTEXPR constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept {
constexpr
#endif
size_type rfind(basic_string_view s, size_type pos = npos) const noexcept {
if (s.size() <= size()) { if (s.size() <= size()) {
for (auto xpos = std::min<size_type>(size() - s.size(), pos);; for (auto xpos = std::min<size_type>(size() - s.size(), pos);;
--xpos) --xpos)
...@@ -400,10 +361,7 @@ public: ...@@ -400,10 +361,7 @@ public:
constexpr size_type rfind(charT const * s, size_type pos = npos) const constexpr size_type rfind(charT const * s, size_type pos = npos) const
{ return rfind(basic_string_view(s), pos); } { return rfind(basic_string_view(s), pos); }
#if HAVE_CXX14_CONSTEXPR constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const
constexpr
#endif
size_type find_first_of(basic_string_view s, size_type pos = 0) const
noexcept noexcept
{ {
for (auto xpos = pos; xpos < size(); ++xpos) { for (auto xpos = pos; xpos < size(); ++xpos) {
...@@ -426,10 +384,7 @@ public: ...@@ -426,10 +384,7 @@ public:
constexpr size_type find_first_of(charT const * s, size_type pos = 0) const constexpr size_type find_first_of(charT const * s, size_type pos = 0) const
{ return find_first_of(basic_string_view(s), pos); } { return find_first_of(basic_string_view(s), pos); }
#if HAVE_CXX14_CONSTEXPR constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const
constexpr
#endif
size_type find_last_of(basic_string_view s, size_type pos = npos) const
noexcept noexcept
{ {
if (!empty()) { if (!empty()) {
...@@ -459,10 +414,7 @@ public: ...@@ -459,10 +414,7 @@ public:
const const
{ return find_last_of(basic_string_view(s), pos); } { return find_last_of(basic_string_view(s), pos); }
#if HAVE_CXX14_CONSTEXPR constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const
constexpr
#endif
size_type find_first_not_of(basic_string_view s, size_type pos = 0) const
noexcept noexcept
{ {
for (auto xpos = pos; xpos < size(); ++xpos) { for (auto xpos = pos; xpos < size(); ++xpos) {
...@@ -492,10 +444,7 @@ public: ...@@ -492,10 +444,7 @@ public:
const const
{ return find_first_not_of(basic_string_view(s), pos); } { return find_first_not_of(basic_string_view(s), pos); }
#if HAVE_CXX14_CONSTEXPR constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const
constexpr
#endif
size_type find_last_not_of(basic_string_view s, size_type pos = npos) const
noexcept noexcept
{ {
if (!empty()) { if (!empty()) {
......
...@@ -25,12 +25,10 @@ ...@@ -25,12 +25,10 @@
#include <cassert> #include <cassert>
#include <type_traits> #include <type_traits>
#include <config_global.h>
namespace o3tl namespace o3tl
{ {
#if HAVE_CXX14_CONSTEXPR #if !defined __COVERITY__
namespace detail { namespace detail {
...@@ -90,7 +88,7 @@ public: ...@@ -90,7 +88,7 @@ public:
typename std::enable_if<std::is_integral<T>::value, int>::type = 0): typename std::enable_if<std::is_integral<T>::value, int>::type = 0):
m_value(value) m_value(value)
{ {
#if !defined __COVERITY__ && HAVE_CXX14_CONSTEXPR #if !defined __COVERITY__
// catch attempts to pass in out-of-range values early // catch attempts to pass in out-of-range values early
assert(detail::isInRange<UNDERLYING_TYPE>(value) assert(detail::isInRange<UNDERLYING_TYPE>(value)
&& "out of range"); && "out of range");
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <cassert> #include <cassert>
#include <type_traits> #include <type_traits>
#include <config_global.h>
#include <sal/types.h> #include <sal/types.h>
namespace o3tl { namespace o3tl {
...@@ -76,14 +75,12 @@ struct is_typed_flags { ...@@ -76,14 +75,12 @@ struct is_typed_flags {
explicit constexpr Wrap(typename std::underlying_type<E>::type value): explicit constexpr Wrap(typename std::underlying_type<E>::type value):
value_(value) value_(value)
{ {
#if HAVE_CXX14_CONSTEXPR
assert(detail::isNonNegative(value)); assert(detail::isNonNegative(value));
assert( assert(
static_cast<typename std::underlying_type<E>::type>(~0) == M static_cast<typename std::underlying_type<E>::type>(~0) == M
// avoid "operands don't affect result" warnings when M // avoid "operands don't affect result" warnings when M
// covers all bits of the underlying type // covers all bits of the underlying type
|| (value & ~M) == 0); || (value & ~M) == 0);
#endif
} }
constexpr operator E() const { return static_cast<E>(value_); } constexpr operator E() const { return static_cast<E>(value_); }
...@@ -105,11 +102,9 @@ struct is_typed_flags { ...@@ -105,11 +102,9 @@ struct is_typed_flags {
template<typename E> template<typename E>
constexpr typename o3tl::typed_flags<E>::Wrap operator ~(E rhs) { constexpr typename o3tl::typed_flags<E>::Wrap operator ~(E rhs) {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
o3tl::typed_flags<E>::mask o3tl::typed_flags<E>::mask
& ~static_cast<typename std::underlying_type<E>::type>(rhs)); & ~static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -126,14 +121,12 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ~( ...@@ -126,14 +121,12 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ~(
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^(
E lhs, E rhs) E lhs, E rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(lhs))); static_cast<typename std::underlying_type<E>::type>(lhs)));
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
^ static_cast<typename std::underlying_type<E>::type>(rhs)); ^ static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -142,11 +135,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^( ...@@ -142,11 +135,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^(
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^(
E lhs, typename o3tl::typed_flags<E>::Wrap rhs) E lhs, typename o3tl::typed_flags<E>::Wrap rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(lhs))); static_cast<typename std::underlying_type<E>::type>(lhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
^ static_cast<typename std::underlying_type<E>::type>(rhs)); ^ static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -155,11 +146,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^( ...@@ -155,11 +146,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^(
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator ^(
typename o3tl::typed_flags<E>::Wrap lhs, E rhs) typename o3tl::typed_flags<E>::Wrap lhs, E rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
^ static_cast<typename std::underlying_type<E>::type>(rhs)); ^ static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -180,14 +169,12 @@ typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator ^( ...@@ -180,14 +169,12 @@ typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator ^(
template<typename E> template<typename E>
constexpr typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) { constexpr typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(lhs))); static_cast<typename std::underlying_type<E>::type>(lhs)));
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
& static_cast<typename std::underlying_type<E>::type>(rhs)); & static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -196,11 +183,9 @@ constexpr typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) { ...@@ -196,11 +183,9 @@ constexpr typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) {
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator &( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator &(
E lhs, typename o3tl::typed_flags<E>::Wrap rhs) E lhs, typename o3tl::typed_flags<E>::Wrap rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(lhs))); static_cast<typename std::underlying_type<E>::type>(lhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
& static_cast<typename std::underlying_type<E>::type>(rhs)); & static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -209,11 +194,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator &( ...@@ -209,11 +194,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator &(
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator &( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator &(
typename o3tl::typed_flags<E>::Wrap lhs, E rhs) typename o3tl::typed_flags<E>::Wrap lhs, E rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
& static_cast<typename std::underlying_type<E>::type>(rhs)); & static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -234,14 +217,12 @@ typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator &( ...@@ -234,14 +217,12 @@ typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator &(
template<typename E> template<typename E>
constexpr typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) { constexpr typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(lhs))); static_cast<typename std::underlying_type<E>::type>(lhs)));
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
| static_cast<typename std::underlying_type<E>::type>(rhs)); | static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -250,11 +231,9 @@ constexpr typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) { ...@@ -250,11 +231,9 @@ constexpr typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) {
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator |( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator |(
E lhs, typename o3tl::typed_flags<E>::Wrap rhs) E lhs, typename o3tl::typed_flags<E>::Wrap rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(lhs))); static_cast<typename std::underlying_type<E>::type>(lhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
| static_cast<typename std::underlying_type<E>::type>(rhs)); | static_cast<typename std::underlying_type<E>::type>(rhs));
...@@ -263,11 +242,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator |( ...@@ -263,11 +242,9 @@ template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator |(
template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator |( template<typename E> constexpr typename o3tl::typed_flags<E>::Wrap operator |(
typename o3tl::typed_flags<E>::Wrap lhs, E rhs) typename o3tl::typed_flags<E>::Wrap lhs, E rhs)
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
o3tl::detail::isNonNegative( o3tl::detail::isNonNegative(
static_cast<typename std::underlying_type<E>::type>(rhs))); static_cast<typename std::underlying_type<E>::type>(rhs)));
#endif
return static_cast<typename o3tl::typed_flags<E>::Wrap>( return static_cast<typename o3tl::typed_flags<E>::Wrap>(
static_cast<typename std::underlying_type<E>::type>(lhs) static_cast<typename std::underlying_type<E>::type>(lhs)
| static_cast<typename std::underlying_type<E>::type>(rhs)); | static_cast<typename std::underlying_type<E>::type>(rhs));
......
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
#include "sal/types.h" #include "sal/types.h"
#if defined LIBO_INTERNAL_ONLY
#include "config_global.h"
#endif
// The unittest uses slightly different code to help check that the proper // The unittest uses slightly different code to help check that the proper
// calls are made. The class is put into a different namespace to make // calls are made. The class is put into a different namespace to make
// sure the compiler generates a different (if generating also non-inline) // sure the compiler generates a different (if generating also non-inline)
...@@ -157,7 +153,7 @@ struct ConstCharArrayDetector< const char[ N ], T > ...@@ -157,7 +153,7 @@ struct ConstCharArrayDetector< const char[ N ], T >
typedef T Type; typedef T Type;
static const std::size_t length = N - 1; static const std::size_t length = N - 1;
static const bool ok = true; static const bool ok = true;
#if defined LIBO_INTERNAL_ONLY && HAVE_CXX14_CONSTEXPR #if defined LIBO_INTERNAL_ONLY
constexpr constexpr
#endif #endif
static bool isValid(char const (& literal)[N]) { static bool isValid(char const (& literal)[N]) {
...@@ -183,7 +179,7 @@ struct ConstCharArrayDetector< const char[ 1 ], T > ...@@ -183,7 +179,7 @@ struct ConstCharArrayDetector< const char[ 1 ], T >
typedef T Type; typedef T Type;
static const std::size_t length = 0; static const std::size_t length = 0;
static const bool ok = true; static const bool ok = true;
#if defined LIBO_INTERNAL_ONLY && HAVE_CXX14_CONSTEXPR #if defined LIBO_INTERNAL_ONLY
constexpr constexpr
#endif #endif
static bool isValid(char const (& literal)[1]) { static bool isValid(char const (& literal)[1]) {
...@@ -202,10 +198,7 @@ struct ConstCharArrayDetector<char8_t const [N], T> { ...@@ -202,10 +198,7 @@ struct ConstCharArrayDetector<char8_t const [N], T> {
using Type = T; using Type = T;
static constexpr bool const ok = true; static constexpr bool const ok = true;
static constexpr std::size_t const length = N - 1; static constexpr std::size_t const length = N - 1;
#if HAVE_CXX14_CONSTEXPR static constexpr bool isValid(char8_t const (& literal)[N]) {
constexpr
#endif
static bool isValid(char8_t const (& literal)[N]) {
for (std::size_t i = 0; i != N - 1; ++i) { for (std::size_t i = 0; i != N - 1; ++i) {
if (literal[i] == u8'\0') { if (literal[i] == u8'\0') {
return false; return false;
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "rtl/textenc.h" #include "rtl/textenc.h"
#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING" #ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
#include "config_global.h"
#include "rtl/stringconcat.hxx" #include "rtl/stringconcat.hxx"
#endif #endif
...@@ -79,10 +78,8 @@ struct SAL_WARN_UNUSED OUStringLiteral ...@@ -79,10 +78,8 @@ struct SAL_WARN_UNUSED OUStringLiteral
data( data(
libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal)) libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal))
{ {
#if HAVE_CXX14_CONSTEXPR
assert( assert(
libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal)); libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
#endif
} }
int size; int size;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <type_traits> #include <type_traits>
#include <memory> #include <memory>
#include <config_global.h>
#include <svl/svldllapi.h> #include <svl/svldllapi.h>
#include <svl/poolitem.hxx> #include <svl/poolitem.hxx>
#include <svl/typedwhich.hxx> #include <svl/typedwhich.hxx>
...@@ -57,9 +56,7 @@ constexpr bool validRanges() { ...@@ -57,9 +56,7 @@ constexpr bool validRanges() {
// std::size_t is no smaller than sal_uInt16: // std::size_t is no smaller than sal_uInt16:
constexpr std::size_t rangeSize(sal_uInt16 wid1, sal_uInt16 wid2) { constexpr std::size_t rangeSize(sal_uInt16 wid1, sal_uInt16 wid2) {
#if HAVE_CXX14_CONSTEXPR
assert(validRange(wid1, wid2)); assert(validRange(wid1, wid2));
#endif
return wid2 - wid1 + 1; return wid2 - wid1 + 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment