[Libreoffice-commits] core.git: include/o3tl

Stephan Bergmann sbergman at redhat.com
Tue Oct 14 05:42:14 PDT 2014


 include/o3tl/typed_flags_set.hxx |   76 +++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 35 deletions(-)

New commits:
commit 950995222509f059037ff7d73e09d5d9ea2b9b2a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 14 14:41:04 2014 +0200

    Reintroduce SFINAE-based selective enablement of &=, |=
    
    ...they had erroneously become unconditionally enabled.  Also, rename Self to
    Wrap.
    
    Change-Id: I574662012bf74114b18f3bab0c1c5825a2bd61bb

diff --git a/include/o3tl/typed_flags_set.hxx b/include/o3tl/typed_flags_set.hxx
index 1aac625..016f8eb 100644
--- a/include/o3tl/typed_flags_set.hxx
+++ b/include/o3tl/typed_flags_set.hxx
@@ -54,9 +54,11 @@ struct is_typed_flags {
     static_assert(
         M >= 0, "is_typed_flags expects only non-negative bit values");
 
-    class Self {
+    typedef E Self;
+
+    class Wrap {
     public:
-        explicit Self(O3TL_STD_UNDERLYING_TYPE_E value):
+        explicit Wrap(O3TL_STD_UNDERLYING_TYPE_E value):
             value_(value)
         { assert(value >= 0); }
 
@@ -82,102 +84,102 @@ struct is_typed_flags {
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator ~(E rhs) {
+inline typename o3tl::typed_flags<E>::Wrap operator ~(E rhs) {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    return static_cast<typename o3tl::typed_flags<E>::Wrap>(
         o3tl::typed_flags<E>::mask
         & ~static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator ~(
-    typename o3tl::typed_flags<E>::Self rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator ~(
+    typename o3tl::typed_flags<E>::Wrap rhs)
 {
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    return static_cast<typename o3tl::typed_flags<E>::Wrap>(
         o3tl::typed_flags<E>::mask
         & ~static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator &(E lhs, E rhs) {
+inline typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator &(
-    E lhs, typename o3tl::typed_flags<E>::Self rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator &(
+    E lhs, typename o3tl::typed_flags<E>::Wrap rhs)
 {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator &(
-    typename o3tl::typed_flags<E>::Self lhs, E rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator &(
+    typename o3tl::typed_flags<E>::Wrap lhs, E rhs)
 {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator &(
-    typename o3tl::typed_flags<E>::Self lhs,
-    typename o3tl::typed_flags<E>::Self rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator &(
+    typename o3tl::typed_flags<E>::Wrap lhs,
+    typename o3tl::typed_flags<E>::Wrap rhs)
 {
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator |(E lhs, E rhs) {
+inline typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator |(
-    E lhs, typename o3tl::typed_flags<E>::Self rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator |(
+    E lhs, typename o3tl::typed_flags<E>::Wrap rhs)
 {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator |(
-    typename o3tl::typed_flags<E>::Self lhs, E rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator |(
+    typename o3tl::typed_flags<E>::Wrap lhs, E rhs)
 {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline typename o3tl::typed_flags<E>::Self operator |(
-    typename o3tl::typed_flags<E>::Self lhs,
-    typename o3tl::typed_flags<E>::Self rhs)
+inline typename o3tl::typed_flags<E>::Wrap operator |(
+    typename o3tl::typed_flags<E>::Wrap lhs,
+    typename o3tl::typed_flags<E>::Wrap rhs)
 {
-    return static_cast<typename o3tl::typed_flags<E>::Self>(
+    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));
 }
 
 template<typename E>
-inline E operator &=(E & lhs, E rhs) {
+inline typename o3tl::typed_flags<E>::Self operator &=(E & lhs, E rhs) {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
     lhs = lhs & rhs;
@@ -185,14 +187,16 @@ inline E operator &=(E & lhs, E rhs) {
 }
 
 template<typename E>
-inline E operator &=(E & lhs, typename o3tl::typed_flags<E>::Self rhs) {
+inline typename o3tl::typed_flags<E>::Self operator &=(
+    E & lhs, typename o3tl::typed_flags<E>::Wrap rhs)
+{
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
     lhs = lhs & rhs;
     return lhs;
 }
 
 template<typename E>
-inline E operator |=(E & lhs, E rhs) {
+inline typename o3tl::typed_flags<E>::Self operator |=(E & lhs, E rhs) {
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(rhs) >= 0);
     lhs = lhs | rhs;
@@ -200,7 +204,9 @@ inline E operator |=(E & lhs, E rhs) {
 }
 
 template<typename E>
-inline E operator |=(E & lhs, typename o3tl::typed_flags<E>::Self rhs) {
+inline typename o3tl::typed_flags<E>::Self operator |=(
+    E & lhs, typename o3tl::typed_flags<E>::Wrap rhs)
+{
     assert(static_cast<O3TL_STD_UNDERLYING_TYPE_E>(lhs) >= 0);
     lhs = lhs | rhs;
     return lhs;


More information about the Libreoffice-commits mailing list