Kaydet (Commit) 7ad4e562 authored tarafından Christoph Lutz's avatar Christoph Lutz Kaydeden (comit) Katarina Behrens

improve fallback behaviour of underlying_type for old gcc

The fix fbd85c25 is not sufficient to build with an old GCC 4.6.
The problem was, that underlying_type returned an int as default
value for GCC 4.6 and int allows negative values that are forbidden
in typed_flags_set.

Changed it to alternative solution suggested in
http://stackoverflow.com/questions/26148192/underlying-type-of-a-c-enum-in-c03

Change-Id: I20f44b8cef9c692efb583971bd251f1c34c289ab
Reviewed-on: https://gerrit.libreoffice.org/15663Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Tested-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 6a26624d
...@@ -19,7 +19,11 @@ namespace o3tl { ...@@ -19,7 +19,11 @@ namespace o3tl {
template<typename T> struct underlying_type { template<typename T> struct underlying_type {
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 6 && \ #if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ <= 6 && \
!defined __clang__ !defined __clang__
typedef int type; typedef typename std::conditional<
T( -1 ) < T( 0 ),
typename std::make_signed< T >::type,
typename std::make_unsigned< T >::type
>::type type;
#else #else
typedef typename std::underlying_type<T>::type type; typedef typename std::underlying_type<T>::type type;
#endif #endif
......
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