cpp-common: remove `cfg-*.hpp` and `log-cfg.hpp`
[babeltrace.git] / src / cpp-common / bt2 / integer-range-set.hpp
index d50fe28558efcdfdd7fec789cdbe2f53858f70ba..1cfbfc3a133ac0ec0b9dc2da6601463a0732ecff 100644 (file)
@@ -12,8 +12,8 @@
 
 #include <babeltrace2/babeltrace.h>
 
+#include "borrowed-object-iterator.hpp"
 #include "borrowed-object.hpp"
-#include "common-iterator.hpp"
 #include "exc.hpp"
 #include "integer-range.hpp"
 #include "internal/utils.hpp"
@@ -138,19 +138,18 @@ private:
     using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
     using typename BorrowedObject<LibObjT>::_LibObjPtr;
     using _ConstLibObjT = typename std::add_const<LibObjT>::type;
-    using _RefFuncs = internal::IntegerRangeSetRefFuncs<_ConstLibObjT>;
     using _Spec = internal::CommonIntegerRangeSetSpec<_ConstLibObjT>;
-    using _ThisCommonIntegerRangeSet = CommonIntegerRangeSet<LibObjT>;
 
 public:
-    using Shared = SharedObject<_ThisCommonIntegerRangeSet, LibObjT, _RefFuncs>;
+    using Shared = SharedObject<CommonIntegerRangeSet, LibObjT,
+                                internal::IntegerRangeSetRefFuncs<_ConstLibObjT>>;
 
     using Range = typename std::conditional<
         std::is_same<_ConstLibObjT, const bt_integer_range_set_unsigned>::value,
         ConstUnsignedIntegerRange, ConstSignedIntegerRange>::type;
 
     using Value = typename Range::Value;
-    using Iterator = CommonIterator<CommonIntegerRangeSet, Range>;
+    using Iterator = BorrowedObjectIterator<CommonIntegerRangeSet>;
 
     explicit CommonIntegerRangeSet(const _LibObjPtr libObjPtr) noexcept :
         _ThisBorrowedObject {libObjPtr}
@@ -172,13 +171,17 @@ public:
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonIntegerRangeSet&
-    operator=(const CommonIntegerRangeSet<OtherLibObjT> rangeSet) noexcept
+    CommonIntegerRangeSet operator=(const CommonIntegerRangeSet<OtherLibObjT> rangeSet) noexcept
     {
         _ThisBorrowedObject::operator=(rangeSet);
         return *this;
     }
 
+    _ConstLibObjT asConst() const noexcept
+    {
+        return _ConstLibObjT {*this};
+    }
+
     template <typename OtherLibObjT>
     bool operator==(const CommonIntegerRangeSet<OtherLibObjT> other) const noexcept
     {
@@ -193,7 +196,9 @@ public:
 
     void addRange(const Value lower, const Value upper) const
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(
+            !std::is_const<LibObjT>::value,
+            "Not available with `bt2::ConstUnsignedIntegerRangeSet` or `bt2::ConstSignedIntegerRangeSet`.");
 
         const auto status = _Spec::addRange(this->libObjPtr(), lower, upper);
 
This page took 0.023536 seconds and 4 git commands to generate.