File tree Expand file tree Collapse file tree 2 files changed +16
-23
lines changed
Expand file tree Collapse file tree 2 files changed +16
-23
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,11 @@ struct emulated_int64_t
5151 constexpr explicit emulated_int64_t (const emulated_uint64_t& other);
5252 #endif
5353
54- NBL_CONSTEXPR_FUNC emulated_int64_t operator-() NBL_CONST_MEMBER_FUNC;
54+ NBL_CONSTEXPR_FUNC emulated_int64_t operator-() NBL_CONST_MEMBER_FUNC
55+ {
56+ storage_t inverted = ~data;
57+ return create (_static_cast<storage_t>(inverted)) + _static_cast<this_t>(1 );
58+ }
5559
5660};
5761
@@ -377,27 +381,6 @@ NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR emulated_uint64_t minus_assign<emulated_uint
377381template<>
378382NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR emulated_int64_t minus_assign<emulated_int64_t>::identity = minus<emulated_int64_t>::identity;
379383
380- // --------------------------------- Unary operators ------------------------------------------
381- // Specializations of the structs found in functional.hlsl
382- template<>
383- struct unary_minus_operator<emulated_int64_t>
384- {
385- using type_t = emulated_int64_t;
386-
387- NBL_CONSTEXPR_FUNC type_t operator ()(NBL_CONST_REF_ARG (type_t) operand)
388- {
389- using storage_t = type_t::storage_t;
390- storage_t inverted = ~operand.data;
391- return type_t::create (_static_cast<storage_t>(inverted)) + _static_cast<type_t>(1 );
392- }
393- };
394-
395- NBL_CONSTEXPR_INLINE_FUNC emulated_int64_t emulated_int64_t::operator-() NBL_CONST_MEMBER_FUNC
396- {
397- unary_minus_operator<emulated_int64_t> unaryMinus;
398- return unaryMinus (NBL_DEREF_THIS);
399- }
400-
401384} //namespace nbl
402385} //namespace hlsl
403386
Original file line number Diff line number Diff line change @@ -495,7 +495,17 @@ struct unary_minus_operator
495495
496496 NBL_CONSTEXPR_FUNC T operator ()(NBL_CONST_REF_ARG (T) operand)
497497 {
498- return -operand;
498+ return operand.operator-();
499+ }
500+ };
501+
502+ template<typename T> NBL_PARTIAL_REQ_TOP (is_fundamental_v<T>)
503+ struct unary_minus_operator<T NBL_PARTIAL_REQ_BOT (is_fundamental_v<T>) >
504+ {
505+ using type_t = T;
506+ NBL_CONSTEXPR_FUNC T operator ()(const T operand)
507+ {
508+ return -operand;
499509 }
500510};
501511
You can’t perform that action at this time.
0 commit comments