diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-06-26 17:28:43 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-26 17:31:14 +0200 |
commit | 3a68a7dcf49f7be95086b747c8426aa310307e49 (patch) | |
tree | 5c5ded4a7b69d4eaff886e7ee35caebf275eb738 /include/o3tl | |
parent | -fsanitize=vptr: SID_ATTR_*LANGUAGE are of type SvxLanguageItem (diff) | |
download | core-3a68a7dcf49f7be95086b747c8426aa310307e49.tar.gz core-3a68a7dcf49f7be95086b747c8426aa310307e49.zip |
Remove workarounds for no longer supported GCC 4.6
In bridges/source/cpp_uno/gcc3_macosx_x86-64/share.hxx, the #if also covered
Clang, which actually needs these declarations (for now; the right fix will
probably be to #include <cxxabi.h>).
Change-Id: I1eebd59e2371f3498d740ab78244927358c4f23f
Diffstat (limited to 'include/o3tl')
-rw-r--r-- | include/o3tl/typed_flags_set.hxx | 115 | ||||
-rw-r--r-- | include/o3tl/underlying_type.hxx | 32 |
2 files changed, 54 insertions, 93 deletions
diff --git a/include/o3tl/typed_flags_set.hxx b/include/o3tl/typed_flags_set.hxx index 01a4009abcc5..76cefc50b32c 100644 --- a/include/o3tl/typed_flags_set.hxx +++ b/include/o3tl/typed_flags_set.hxx @@ -46,14 +46,6 @@ typename std::enable_if<std::is_unsigned<T>::value, bool>::type isNonNegative(T) template<typename T> struct typed_flags {}; -#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 6 && \ - !defined __clang__ -// use largest sensible unsigned type as fallback -#define O3TL_STD_UNDERLYING_TYPE_E unsigned long long -#else -#define O3TL_STD_UNDERLYING_TYPE_E typename std::underlying_type<E>::type -#endif - /// Mark a (scoped) enumeration as a set of bit flags, with accompanying /// operations. /// @@ -67,7 +59,7 @@ template<typename T> struct typed_flags {}; /// /// \param E the enumeration type. /// \param M the all-bits-set value for the bit flags. -template<typename E, O3TL_STD_UNDERLYING_TYPE_E M> +template<typename E, typename std::underlying_type<E>::type M> struct is_typed_flags { static_assert( M >= 0, "is_typed_flags expects only non-negative bit values"); @@ -76,21 +68,22 @@ struct is_typed_flags { class Wrap { public: - explicit Wrap(O3TL_STD_UNDERLYING_TYPE_E value): + explicit Wrap(typename std::underlying_type<E>::type value): value_(value) { assert(detail::isNonNegative(value)); } operator E() { return static_cast<E>(value_); } - explicit operator O3TL_STD_UNDERLYING_TYPE_E() { return value_; } + explicit operator typename std::underlying_type<E>::type() + { return value_; } explicit operator bool() { return value_ != 0; } private: - O3TL_STD_UNDERLYING_TYPE_E value_; + typename std::underlying_type<E>::type value_; }; - static O3TL_STD_UNDERLYING_TYPE_E const mask = M; + static typename std::underlying_type<E>::type const mask = M; }; } @@ -99,10 +92,10 @@ template<typename E> inline typename o3tl::typed_flags<E>::Wrap operator ~(E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( o3tl::typed_flags<E>::mask - & ~static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + & ~static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -111,20 +104,20 @@ inline typename o3tl::typed_flags<E>::Wrap operator ~( { return static_cast<typename o3tl::typed_flags<E>::Wrap>( o3tl::typed_flags<E>::mask - & ~static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + & ~static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> inline typename o3tl::typed_flags<E>::Wrap operator ^(E lhs, E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - ^ static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -133,10 +126,10 @@ inline typename o3tl::typed_flags<E>::Wrap operator ^( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - ^ static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -145,10 +138,10 @@ inline typename o3tl::typed_flags<E>::Wrap operator ^( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - ^ static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -157,21 +150,21 @@ inline typename o3tl::typed_flags<E>::Wrap operator ^( typename o3tl::typed_flags<E>::Wrap rhs) { return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - ^ static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> inline typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - & static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -180,10 +173,10 @@ inline typename o3tl::typed_flags<E>::Wrap operator &( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - & static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -192,10 +185,10 @@ inline typename o3tl::typed_flags<E>::Wrap operator &( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - & static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -204,21 +197,21 @@ inline typename o3tl::typed_flags<E>::Wrap operator &( typename o3tl::typed_flags<E>::Wrap rhs) { return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - & static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> inline typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - | static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -227,10 +220,10 @@ inline typename o3tl::typed_flags<E>::Wrap operator |( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - | static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -239,10 +232,10 @@ inline typename o3tl::typed_flags<E>::Wrap operator |( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - | static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> @@ -251,18 +244,18 @@ inline typename o3tl::typed_flags<E>::Wrap operator |( typename o3tl::typed_flags<E>::Wrap rhs) { return static_cast<typename o3tl::typed_flags<E>::Wrap>( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) - | static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs)); + static_cast<typename std::underlying_type<E>::type>(lhs) + | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> inline typename o3tl::typed_flags<E>::Self operator &=(E & lhs, E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); lhs = lhs & rhs; return lhs; } @@ -273,7 +266,7 @@ inline typename o3tl::typed_flags<E>::Self operator &=( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); lhs = lhs & rhs; return lhs; } @@ -282,10 +275,10 @@ template<typename E> inline typename o3tl::typed_flags<E>::Self operator |=(E & lhs, E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); lhs = lhs | rhs; return lhs; } @@ -296,7 +289,7 @@ inline typename o3tl::typed_flags<E>::Self operator |=( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); lhs = lhs | rhs; return lhs; } @@ -305,10 +298,10 @@ template<typename E> inline typename o3tl::typed_flags<E>::Self operator ^=(E & lhs, E rhs) { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs))); + static_cast<typename std::underlying_type<E>::type>(rhs))); lhs = lhs ^ rhs; return lhs; } @@ -319,7 +312,7 @@ inline typename o3tl::typed_flags<E>::Self operator ^=( { assert( o3tl::detail::isNonNegative( - static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs))); + static_cast<typename std::underlying_type<E>::type>(lhs))); lhs = lhs ^ rhs; return lhs; } diff --git a/include/o3tl/underlying_type.hxx b/include/o3tl/underlying_type.hxx deleted file mode 100644 index 4b2e0778ee60..000000000000 --- a/include/o3tl/underlying_type.hxx +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_O3TL_UNDERLYING_TYPE_HXX -#define INCLUDED_O3TL_UNDERLYING_TYPE_HXX - -#include <sal/config.h> - -#include <type_traits> - -namespace o3tl { - -template<typename T> struct underlying_type { -#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 6 && \ - !defined __clang__ - typedef int type; -#else - typedef typename std::underlying_type<T>::type type; -#endif -}; - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |