Remove some unused includes in C++ files
[babeltrace.git] / src / cpp-common / bt2 / trace-ir.hpp
index 87f51b9a2b483d052b983d9f9f08ad39a26af784..f27a87aee01e7b11ddc1bafd1d4c4b6090c38e2b 100644 (file)
@@ -7,19 +7,20 @@
 #ifndef BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP
 #define BABELTRACE_CPP_COMMON_BT2_TRACE_IR_HPP
 
-#include <type_traits>
 #include <cstdint>
+#include <type_traits>
+
 #include <babeltrace2/babeltrace.h>
 
-#include "internal/borrowed-obj.hpp"
 #include "cpp-common/optional.hpp"
 #include "cpp-common/string_view.hpp"
+
 #include "clock-class.hpp"
-#include "clock-snapshot.hpp"
 #include "field-class.hpp"
 #include "field.hpp"
-#include "value.hpp"
+#include "internal/borrowed-obj.hpp"
 #include "internal/utils.hpp"
+#include "value.hpp"
 
 namespace bt2 {
 
@@ -151,12 +152,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 +331,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;
@@ -368,7 +369,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -508,12 +509,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;
@@ -526,7 +527,7 @@ public:
         const auto libObjPtr = bt_packet_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return Packet::Shared {Packet {libObjPtr}};
+        return Packet::Shared::createWithoutRef(libObjPtr);
     }
 
     CommonStreamClass<const bt_stream_class> cls() const noexcept;
@@ -546,7 +547,7 @@ public:
         const auto status = bt_stream_set_name(this->libObjPtr(), name);
 
         if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -567,7 +568,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`.");
 
@@ -586,7 +587,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -747,12 +748,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;
@@ -768,7 +769,7 @@ public:
         const auto status = bt_trace_set_name(this->libObjPtr(), name);
 
         if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -788,9 +789,9 @@ public:
         return nonstd::nullopt;
     }
 
-    void uuid(const std::uint8_t * const uuid) noexcept
+    void uuid(const bt2_common::UuidView& uuid) noexcept
     {
-        bt_trace_set_uuid(this->libObjPtr(), uuid);
+        bt_trace_set_uuid(this->libObjPtr(), uuid.begin());
     }
 
     nonstd::optional<bt2_common::UuidView> uuid() const noexcept
@@ -848,7 +849,7 @@ public:
         const auto status = bt_trace_set_environment_entry_integer(this->libObjPtr(), name, val);
 
         if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -864,7 +865,7 @@ public:
         const auto status = bt_trace_set_environment_entry_string(this->libObjPtr(), name, val);
 
         if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -916,7 +917,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`.");
 
@@ -935,7 +936,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -1094,13 +1095,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;
@@ -1121,7 +1122,7 @@ public:
         const auto status = bt_event_class_set_name(this->libObjPtr(), name);
 
         if (status == BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1168,7 +1169,7 @@ public:
         const auto status = bt_event_class_set_emf_uri(this->libObjPtr(), emfUri);
 
         if (status == BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1188,7 +1189,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`.");
 
@@ -1196,7 +1197,7 @@ public:
             bt_event_class_set_payload_field_class(this->libObjPtr(), fc.libObjPtr());
 
         if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1222,7 +1223,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`.");
 
@@ -1230,7 +1231,7 @@ public:
             bt_event_class_set_specific_context_field_class(this->libObjPtr(), fc.libObjPtr());
 
         if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1257,7 +1258,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`.");
 
@@ -1276,7 +1277,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -1458,36 +1459,36 @@ 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`.");
 
         const auto libObjPtr = bt_stream_create(this->libObjPtr(), trace.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return Stream::Shared {Stream {libObjPtr}};
+        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`.");
 
         const auto libObjPtr = bt_stream_create_with_id(this->libObjPtr(), trace.libObjPtr(), id);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return Stream::Shared {Stream {libObjPtr}};
+        return Stream::Shared::createWithoutRef(libObjPtr);
     }
 
     EventClass::Shared createEventClass()
@@ -1497,7 +1498,7 @@ public:
         const auto libObjPtr = bt_event_class_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return EventClass::Shared {EventClass {libObjPtr}};
+        return EventClass::Shared::createWithoutRef(libObjPtr);
     }
 
     EventClass::Shared createEventClass(const std::uint64_t id)
@@ -1507,7 +1508,7 @@ public:
         const auto libObjPtr = bt_event_class_create_with_id(this->libObjPtr(), id);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return EventClass::Shared {EventClass {libObjPtr}};
+        return EventClass::Shared::createWithoutRef(libObjPtr);
     }
 
     CommonTraceClass<const bt_trace_class> traceClass() const noexcept;
@@ -1525,7 +1526,7 @@ public:
         const auto status = bt_stream_class_set_name(this->libObjPtr(), name);
 
         if (status == BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1642,7 +1643,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 +1712,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`.");
 
@@ -1719,7 +1720,7 @@ public:
             bt_stream_class_set_packet_context_field_class(this->libObjPtr(), fc.libObjPtr());
 
         if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1745,7 +1746,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`.");
 
@@ -1753,7 +1754,7 @@ public:
             bt_stream_class_set_event_common_context_field_class(this->libObjPtr(), fc.libObjPtr());
 
         if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
-            throw LibMemoryError {};
+            throw MemoryError {};
         }
     }
 
@@ -1780,7 +1781,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`.");
 
@@ -1799,7 +1800,7 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
@@ -1940,26 +1941,26 @@ 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`.");
 
         const auto libObjPtr = bt_trace_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return Trace::Shared {Trace {libObjPtr}};
+        return Trace::Shared::createWithoutRef(libObjPtr);
     }
 
     StreamClass::Shared createStreamClass()
@@ -1969,7 +1970,7 @@ public:
         const auto libObjPtr = bt_stream_class_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return StreamClass::Shared {StreamClass {libObjPtr}};
+        return StreamClass::Shared::createWithoutRef(libObjPtr);
     }
 
     StreamClass::Shared createStreamClass(const std::uint64_t id)
@@ -1979,7 +1980,7 @@ public:
         const auto libObjPtr = bt_stream_class_create_with_id(this->libObjPtr(), id);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return StreamClass::Shared {StreamClass {libObjPtr}};
+        return StreamClass::Shared::createWithoutRef(libObjPtr);
     }
 
     FieldClass::Shared createBoolFieldClass()
@@ -1989,7 +1990,7 @@ public:
         const auto libObjPtr = bt_field_class_bool_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return FieldClass::Shared {FieldClass {libObjPtr}};
+        return FieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     BitArrayFieldClass::Shared createBitArrayFieldClass(const std::uint64_t length)
@@ -1999,7 +2000,7 @@ public:
         const auto libObjPtr = bt_field_class_bit_array_create(this->libObjPtr(), length);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return BitArrayFieldClass::Shared {BitArrayFieldClass {libObjPtr}};
+        return BitArrayFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     IntegerFieldClass::Shared createUnsignedIntegerFieldClass()
@@ -2009,7 +2010,7 @@ public:
         const auto libObjPtr = bt_field_class_integer_unsigned_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return IntegerFieldClass::Shared {IntegerFieldClass {libObjPtr}};
+        return IntegerFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     IntegerFieldClass::Shared createSignedIntegerFieldClass()
@@ -2019,7 +2020,7 @@ public:
         const auto libObjPtr = bt_field_class_integer_signed_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return IntegerFieldClass::Shared {IntegerFieldClass {libObjPtr}};
+        return IntegerFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     UnsignedEnumerationFieldClass::Shared createUnsignedEnumerationFieldClass()
@@ -2029,7 +2030,7 @@ public:
         const auto libObjPtr = bt_field_class_enumeration_unsigned_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return UnsignedEnumerationFieldClass::Shared {UnsignedEnumerationFieldClass {libObjPtr}};
+        return UnsignedEnumerationFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     SignedEnumerationFieldClass::Shared createSignedEnumerationFieldClass()
@@ -2039,7 +2040,7 @@ public:
         const auto libObjPtr = bt_field_class_enumeration_signed_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return SignedEnumerationFieldClass::Shared {SignedEnumerationFieldClass {libObjPtr}};
+        return SignedEnumerationFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     FieldClass::Shared createSinglePrecisionRealFieldClass()
@@ -2049,7 +2050,7 @@ public:
         const auto libObjPtr = bt_field_class_real_single_precision_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return FieldClass::Shared {FieldClass {libObjPtr}};
+        return FieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     FieldClass::Shared createDoublePrecisionRealFieldClass()
@@ -2059,7 +2060,7 @@ public:
         const auto libObjPtr = bt_field_class_real_double_precision_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return FieldClass::Shared {FieldClass {libObjPtr}};
+        return FieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     FieldClass::Shared createStringFieldClass()
@@ -2069,10 +2070,10 @@ public:
         const auto libObjPtr = bt_field_class_string_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return FieldClass::Shared {FieldClass {libObjPtr}};
+        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`.");
@@ -2081,10 +2082,10 @@ public:
             this->libObjPtr(), elementFieldClass.libObjPtr(), length);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return StaticArrayFieldClass::Shared {StaticArrayFieldClass {libObjPtr}};
+        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`.");
 
@@ -2092,12 +2093,12 @@ public:
             this->libObjPtr(), elementFieldClass.libObjPtr(), nullptr);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return ArrayFieldClass::Shared {ArrayFieldClass {libObjPtr}};
+        return ArrayFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     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`.");
 
@@ -2105,8 +2106,7 @@ public:
             this->libObjPtr(), elementFieldClass.libObjPtr(), lengthFieldClass.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return DynamicArrayWithLengthFieldClass::Shared {
-            DynamicArrayWithLengthFieldClass {libObjPtr}};
+        return DynamicArrayWithLengthFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     StructureFieldClass::Shared createStructureFieldClass()
@@ -2116,10 +2116,10 @@ public:
         const auto libObjPtr = bt_field_class_structure_create(this->libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return StructureFieldClass::Shared {StructureFieldClass {libObjPtr}};
+        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`.");
 
@@ -2127,12 +2127,12 @@ public:
             this->libObjPtr(), optionalFieldClass.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return OptionFieldClass::Shared {OptionFieldClass {libObjPtr}};
+        return OptionFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     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`.");
 
@@ -2140,14 +2140,13 @@ public:
             this->libObjPtr(), optionalFieldClass.libObjPtr(), selectorFieldClass.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return OptionWithBoolSelectorFieldClass::Shared {
-            OptionWithBoolSelectorFieldClass {libObjPtr}};
+        return OptionWithBoolSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     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`.");
 
@@ -2156,14 +2155,13 @@ public:
             ranges.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return OptionWithUnsignedIntegerSelectorFieldClass::Shared {
-            OptionWithUnsignedIntegerSelectorFieldClass {libObjPtr}};
+        return OptionWithUnsignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     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`.");
 
@@ -2172,8 +2170,7 @@ public:
             ranges.libObjPtr());
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return OptionWithSignedIntegerSelectorFieldClass::Shared {
-            OptionWithSignedIntegerSelectorFieldClass {libObjPtr}};
+        return OptionWithSignedIntegerSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     VariantWithoutSelectorFieldClass::Shared createVariantFieldClass()
@@ -2183,24 +2180,21 @@ public:
         const auto libObjPtr = bt_field_class_variant_create(this->libObjPtr(), nullptr);
 
         internal::validateCreatedObjPtr(libObjPtr);
-        return VariantWithoutSelectorFieldClass::Shared {
-            VariantWithoutSelectorFieldClass {libObjPtr}};
+        return VariantWithoutSelectorFieldClass::Shared::createWithoutRef(libObjPtr);
     }
 
     VariantWithUnsignedIntegerSelectorFieldClass::Shared
-    createVariantWithUnsignedIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass)
+    createVariantWithUnsignedIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass)
     {
-        return VariantWithUnsignedIntegerSelectorFieldClass::Shared {
-            VariantWithUnsignedIntegerSelectorFieldClass {
-                this->_createVariantWithIntegerSelectorFieldClass(selectorFieldClass)}};
+        return this->_createVariantWithIntegerSelectorFieldClass<
+            VariantWithUnsignedIntegerSelectorFieldClass>(selectorFieldClass);
     }
 
     VariantWithSignedIntegerSelectorFieldClass::Shared
-    createVariantWithSignedIntegerSelectorFieldClass(const IntegerFieldClass& selectorFieldClass)
+    createVariantWithSignedIntegerSelectorFieldClass(const IntegerFieldClass selectorFieldClass)
     {
-        return VariantWithSignedIntegerSelectorFieldClass::Shared {
-            VariantWithSignedIntegerSelectorFieldClass {
-                this->_createVariantWithIntegerSelectorFieldClass(selectorFieldClass)}};
+        return this->_createVariantWithIntegerSelectorFieldClass<
+            VariantWithSignedIntegerSelectorFieldClass>(selectorFieldClass);
     }
 
     void assignsAutomaticStreamClassId(const bool val) noexcept
@@ -2255,7 +2249,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`.");
 
@@ -2274,12 +2268,13 @@ public:
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 
 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`.");
 
@@ -2287,7 +2282,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.039566 seconds and 4 git commands to generate.