3333#include " core/variant/variant.h"
3434
3535template <typename T>
36- class RequiredValue {
36+ class RequiredResult {
3737 // We can't explicitly check if the type is an Object here, as it might've been forward-declared.
3838 // However, we can at least assert that it's an unqualified, non-builtin type.
3939 static_assert (!std::is_scalar_v<T>, " T may not be a scalar type" );
@@ -47,64 +47,66 @@ class RequiredValue {
4747private:
4848 value_type _value;
4949
50- _FORCE_INLINE_ RequiredValue () {
50+ _FORCE_INLINE_ RequiredResult () {
5151 if constexpr (!std::is_base_of_v<RefCounted, T>) {
5252 _value = nullptr ;
5353 }
5454 }
5555
5656public:
57- RequiredValue (const RequiredValue &p_other) = default ;
58- RequiredValue (RequiredValue &&p_other) = default ;
59- RequiredValue &operator =(const RequiredValue &p_other) = default ;
60- RequiredValue &operator =(RequiredValue &&p_other) = default ;
57+ RequiredResult (const RequiredResult &p_other) = default ;
58+ RequiredResult (RequiredResult &&p_other) = default ;
59+ RequiredResult &operator =(const RequiredResult &p_other) = default ;
60+ RequiredResult &operator =(RequiredResult &&p_other) = default ;
6161
62- _FORCE_INLINE_ RequiredValue (std::nullptr_t ) :
63- RequiredValue () {}
64- _FORCE_INLINE_ RequiredValue &operator =(std::nullptr_t ) { _value = nullptr ; }
62+ _FORCE_INLINE_ RequiredResult (std::nullptr_t ) :
63+ RequiredResult () {}
64+ _FORCE_INLINE_ RequiredResult &operator =(std::nullptr_t ) { _value = nullptr ; }
6565
6666 [[nodiscard, deprecated(" Should not be called directly; only for internal use." )]]
67- _FORCE_INLINE_ static RequiredValue<T> err_return () { return RequiredValue<T>(); }
67+ _FORCE_INLINE_ value_type _internal_ptr () const { return _value; }
68+ [[nodiscard, deprecated(" Should not be called directly; only for internal use." )]]
69+ _FORCE_INLINE_ static RequiredResult<T> err_return () { return RequiredResult<T>(); }
6870
6971 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
70- _FORCE_INLINE_ RequiredValue (const RequiredValue <T_Other> &p_other) :
72+ _FORCE_INLINE_ RequiredResult (const RequiredResult <T_Other> &p_other) :
7173 _value(p_other._value) {}
7274 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
73- _FORCE_INLINE_ RequiredValue &operator =(const RequiredValue <T_Other> &p_other) {
75+ _FORCE_INLINE_ RequiredResult &operator =(const RequiredResult <T_Other> &p_other) {
7476 _value = p_other._value ;
7577 return *this ;
7678 }
7779
7880 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
79- _FORCE_INLINE_ RequiredValue (const T_Other *p_ptr) :
81+ _FORCE_INLINE_ RequiredResult (const T_Other *p_ptr) :
8082 _value(const_cast <std::remove_const_t <T_Other> *>(p_ptr)) {}
8183 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
82- _FORCE_INLINE_ RequiredValue &operator =(const T_Other *p_ptr) {
84+ _FORCE_INLINE_ RequiredResult &operator =(const T_Other *p_ptr) {
8385 _value = const_cast <std::remove_const_t <T_Other> *>(p_ptr);
8486 return *this ;
8587 }
8688
8789 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
88- _FORCE_INLINE_ RequiredValue (const Ref<T_Other> &p_ref) :
90+ _FORCE_INLINE_ RequiredResult (const Ref<T_Other> &p_ref) :
8991 _value(p_ref) {}
9092 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
91- _FORCE_INLINE_ RequiredValue &operator =(const Ref<T_Other> &p_ref) {
93+ _FORCE_INLINE_ RequiredResult &operator =(const Ref<T_Other> &p_ref) {
9294 _value = p_ref;
9395 return *this ;
9496 }
9597
9698 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
97- _FORCE_INLINE_ RequiredValue (Ref<T_Other> &&p_ref) :
99+ _FORCE_INLINE_ RequiredResult (Ref<T_Other> &&p_ref) :
98100 _value(std::move(p_ref)) {}
99101 template <typename T_Other, std::enable_if_t <std::is_base_of_v<T, T_Other>, int > = 0 >
100- _FORCE_INLINE_ RequiredValue &operator =(Ref<T_Other> &&p_ref) {
102+ _FORCE_INLINE_ RequiredResult &operator =(Ref<T_Other> &&p_ref) {
101103 _value = std::move (p_ref);
102104 return &this ;
103105 }
104106
105- _FORCE_INLINE_ RequiredValue (const Variant &p_variant) :
107+ _FORCE_INLINE_ RequiredResult (const Variant &p_variant) :
106108 _value(static_cast <T *>(p_variant.get_validated_object())) {}
107- _FORCE_INLINE_ RequiredValue &operator =(const Variant &p_variant) {
109+ _FORCE_INLINE_ RequiredResult &operator =(const Variant &p_variant) {
108110 _value = static_cast <T *>(p_variant.get_validated_object ());
109111 return *this ;
110112 }
@@ -251,6 +253,6 @@ class RequiredParam {
251253
252254// Technically zero-constructible, but not recommended.
253255template <typename T>
254- struct is_zero_constructible <RequiredValue <T>> : std::true_type {};
256+ struct is_zero_constructible <RequiredResult <T>> : std::true_type {};
255257template <typename T>
256258struct is_zero_constructible <RequiredParam<T>> : std::true_type {};
0 commit comments