Fix: trace-ir.hpp: spurious reference on object creation
[babeltrace.git] / src / cpp-common / bt2 / trace-ir.hpp
index 5881092b384b1b2a12943149105dc1126fa903ce..a7576a56ce62607a6c39c01fa4249b30a999feeb 100644 (file)
@@ -151,12 +151,12 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonEvent(const CommonEvent<OtherLibObjT>& event) noexcept : _ThisBorrowedObj {event}
+    CommonEvent(const CommonEvent<OtherLibObjT> event) noexcept : _ThisBorrowedObj {event}
     {
     }
 
     template <typename OtherLibObjT>
-    CommonEvent<LibObjT>& operator=(const CommonEvent<OtherLibObjT>& event) noexcept
+    CommonEvent<LibObjT>& operator=(const CommonEvent<OtherLibObjT> event) noexcept
     {
         _ThisBorrowedObj::operator=(event);
         return *this;
@@ -330,12 +330,12 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonPacket(const CommonPacket<OtherLibObjT>& packet) noexcept : _ThisBorrowedObj {packet}
+    CommonPacket(const CommonPacket<OtherLibObjT> packet) noexcept : _ThisBorrowedObj {packet}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonPacket& operator=(const CommonPacket<OtherLibObjT>& packet) noexcept
+    _ThisCommonPacket& operator=(const CommonPacket<OtherLibObjT> packet) noexcept
     {
         _ThisBorrowedObj::operator=(packet);
         return *this;
@@ -508,12 +508,12 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonStream(const CommonStream<OtherLibObjT>& stream) noexcept : _ThisBorrowedObj {stream}
+    CommonStream(const CommonStream<OtherLibObjT> stream) noexcept : _ThisBorrowedObj {stream}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonStream& operator=(const CommonStream<OtherLibObjT>& stream) noexcept
+    _ThisCommonStream& operator=(const CommonStream<OtherLibObjT> stream) noexcept
     {
         _ThisBorrowedObj::operator=(stream);
         return *this;
@@ -567,7 +567,7 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+    void userAttributes(const CommonMapValue<LibValT> userAttrs)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -747,12 +747,12 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonTrace(const CommonTrace<OtherLibObjT>& trace) noexcept : _ThisBorrowedObj {trace}
+    CommonTrace(const CommonTrace<OtherLibObjT> trace) noexcept : _ThisBorrowedObj {trace}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonTrace& operator=(const CommonTrace<OtherLibObjT>& trace) noexcept
+    _ThisCommonTrace& operator=(const CommonTrace<OtherLibObjT> trace) noexcept
     {
         _ThisBorrowedObj::operator=(trace);
         return *this;
@@ -916,7 +916,7 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+    void userAttributes(const CommonMapValue<LibValT> userAttrs)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1094,13 +1094,13 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonEventClass(const CommonEventClass<OtherLibObjT>& eventClass) noexcept :
+    CommonEventClass(const CommonEventClass<OtherLibObjT> eventClass) noexcept :
         _ThisBorrowedObj {eventClass}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonEventClass& operator=(const CommonEventClass<OtherLibObjT>& eventClass) noexcept
+    _ThisCommonEventClass& operator=(const CommonEventClass<OtherLibObjT> eventClass) noexcept
     {
         _ThisBorrowedObj::operator=(eventClass);
         return *this;
@@ -1188,7 +1188,7 @@ public:
         return nonstd::nullopt;
     }
 
-    void payloadFieldClass(const StructureFieldClass& fc)
+    void payloadFieldClass(const StructureFieldClass fc)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1222,7 +1222,7 @@ public:
         return nonstd::nullopt;
     }
 
-    void specificContextFieldClass(const StructureFieldClass& fc)
+    void specificContextFieldClass(const StructureFieldClass fc)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1257,7 +1257,7 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+    void userAttributes(const CommonMapValue<LibValT> userAttrs)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1458,19 +1458,19 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonStreamClass(const CommonStreamClass<OtherLibObjT>& streamClass) noexcept :
+    CommonStreamClass(const CommonStreamClass<OtherLibObjT> streamClass) noexcept :
         _ThisBorrowedObj {streamClass}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonStreamClass& operator=(const CommonStreamClass<OtherLibObjT>& streamClass) noexcept
+    _ThisCommonStreamClass& operator=(const CommonStreamClass<OtherLibObjT> streamClass) noexcept
     {
         _ThisBorrowedObj::operator=(streamClass);
         return *this;
     }
 
-    Stream::Shared instantiate(const Trace& trace)
+    Stream::Shared instantiate(const Trace trace)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1480,7 +1480,7 @@ public:
         return Stream::Shared::createWithoutRef(libObjPtr);
     }
 
-    Stream::Shared instantiate(const Trace& trace, const std::uint64_t id)
+    Stream::Shared instantiate(const Trace trace, const std::uint64_t id)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1642,7 +1642,7 @@ public:
             bt_stream_class_discarded_packets_have_default_clock_snapshots(this->libObjPtr()));
     }
 
-    void defaultClockClass(const ClockClass& clkCls)
+    void defaultClockClass(const ClockClass clkCls)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1711,7 +1711,7 @@ public:
         return nonstd::nullopt;
     }
 
-    void packetContextFieldClass(const StructureFieldClass& fc)
+    void packetContextFieldClass(const StructureFieldClass fc)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1745,7 +1745,7 @@ public:
         return nonstd::nullopt;
     }
 
-    void eventCommonContextFieldClass(const StructureFieldClass& fc)
+    void eventCommonContextFieldClass(const StructureFieldClass fc)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1780,7 +1780,7 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+    void userAttributes(const CommonMapValue<LibValT> userAttrs)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -1940,19 +1940,19 @@ public:
     }
 
     template <typename OtherLibObjT>
-    CommonTraceClass(const CommonTraceClass<OtherLibObjT>& traceClass) noexcept :
+    CommonTraceClass(const CommonTraceClass<OtherLibObjT> traceClass) noexcept :
         _ThisBorrowedObj {traceClass}
     {
     }
 
     template <typename OtherLibObjT>
-    _ThisCommonTraceClass& operator=(const CommonTraceClass<OtherLibObjT>& traceClass) noexcept
+    _ThisCommonTraceClass& operator=(const CommonTraceClass<OtherLibObjT> traceClass) noexcept
     {
         _ThisBorrowedObj::operator=(traceClass);
         return *this;
     }
 
-    Trace::Shared instantiate(const Trace& trace)
+    Trace::Shared instantiate()
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2072,7 +2072,7 @@ public:
         return FieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
-    StaticArrayFieldClass::Shared createStaticArrayFieldClass(const FieldClass& elementFieldClass,
+    StaticArrayFieldClass::Shared createStaticArrayFieldClass(const FieldClass elementFieldClass,
                                                               const std::uint64_t length)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
@@ -2084,7 +2084,7 @@ public:
         return StaticArrayFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
-    ArrayFieldClass::Shared createDynamicArrayFieldClass(const FieldClass& elementFieldClass)
+    ArrayFieldClass::Shared createDynamicArrayFieldClass(const FieldClass elementFieldClass)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2096,8 +2096,8 @@ public:
     }
 
     DynamicArrayWithLengthFieldClass::Shared
-    createDynamicArrayFieldClass(const FieldClass& elementFieldClass,
-                                 const IntegerFieldClass& lengthFieldClass)
+    createDynamicArrayFieldClass(const FieldClass elementFieldClass,
+                                 const IntegerFieldClass lengthFieldClass)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2118,7 +2118,7 @@ public:
         return StructureFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
-    OptionFieldClass::Shared createOptionFieldClass(const FieldClass& optionalFieldClass)
+    OptionFieldClass::Shared createOptionFieldClass(const FieldClass optionalFieldClass)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2130,8 +2130,8 @@ public:
     }
 
     OptionWithBoolSelectorFieldClass::Shared
-    createOptionWithBoolSelectorFieldClass(const FieldClass& optionalFieldClass,
-                                           const FieldClass& selectorFieldClass)
+    createOptionWithBoolSelectorFieldClass(const FieldClass optionalFieldClass,
+                                           const FieldClass selectorFieldClass)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2143,9 +2143,9 @@ public:
     }
 
     OptionWithUnsignedIntegerSelectorFieldClass::Shared
-    createOptionWithUnsignedIntegerSelectorFieldClass(const FieldClass& optionalFieldClass,
-                                                      const IntegerFieldClass& selectorFieldClass,
-                                                      const ConstUnsignedIntegerRangeSet& ranges)
+    createOptionWithUnsignedIntegerSelectorFieldClass(const FieldClass optionalFieldClass,
+                                                      const IntegerFieldClass selectorFieldClass,
+                                                      const ConstUnsignedIntegerRangeSet ranges)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2158,9 +2158,9 @@ public:
     }
 
     OptionWithSignedIntegerSelectorFieldClass::Shared
-    createOptionWithSignedIntegerSelectorFieldClass(const FieldClass& optionalFieldClass,
-                                                    const IntegerFieldClass& selectorFieldClass,
-                                                    const ConstSignedIntegerRangeSet& ranges)
+    createOptionWithSignedIntegerSelectorFieldClass(const FieldClass optionalFieldClass,
+                                                    const IntegerFieldClass selectorFieldClass,
+                                                    const ConstSignedIntegerRangeSet ranges)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2183,19 +2183,17 @@ public:
     }
 
     VariantWithUnsignedIntegerSelectorFieldClass::Shared
-    createVariantWithUnsignedIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass)
+    createVariantWithUnsignedIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass)
     {
-        return VariantWithUnsignedIntegerSelectorFieldClass {
-            this->_createVariantWithIntegerSelectorFieldClass(selectorFieldClass)}
-            .shared();
+        return this->_createVariantWithIntegerSelectorFieldClass<
+            VariantWithUnsignedIntegerSelectorFieldClass>(selectorFieldClass);
     }
 
     VariantWithSignedIntegerSelectorFieldClass::Shared
-    createVariantWithSignedIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass)
+    createVariantWithSignedIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass)
     {
-        return VariantWithSignedIntegerSelectorFieldClass {
-            this->_createVariantWithIntegerSelectorFieldClass(selectorFieldClass)}
-            .shared();
+        return this->_createVariantWithIntegerSelectorFieldClass<
+            VariantWithSignedIntegerSelectorFieldClass>(selectorFieldClass);
     }
 
     void assignsAutomaticStreamClassId(const bool val) noexcept
@@ -2250,7 +2248,7 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT>& userAttrs)
+    void userAttributes(const CommonMapValue<LibValT> userAttrs)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2273,8 +2271,9 @@ public:
     }
 
 private:
-    bt_field_class *
-    _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass)
+    template <typename ObjT>
+    typename ObjT::Shared
+    _createVariantWithIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass)
     {
         static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
 
@@ -2282,7 +2281,7 @@ private:
             bt_field_class_variant_create(this->libObjPtr(), selectorFieldClass.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return libObjPtr;
+        return ObjT::Shared::createWithoutRef(libObjPtr);
     }
 };
 
This page took 0.032603 seconds and 4 git commands to generate.