瀏覽代碼

fixed_point: Mark copy/move assignment operators and constructors as constexpr

Given these are just moving a raw value around, these can sensibly be
made constexpr to make the interface more useful.
Lioncash 3 年之前
父節點
當前提交
b6119a55f9
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/common/fixed_point.h

+ 6 - 3
src/common/fixed_point.h

@@ -268,9 +268,12 @@ public:
 
 public: // constructors
     FixedPoint() = default;
-    FixedPoint(const FixedPoint&) = default;
-    FixedPoint(FixedPoint&&) noexcept = default;
-    FixedPoint& operator=(const FixedPoint&) = default;
+
+    constexpr FixedPoint(const FixedPoint&) = default;
+    constexpr FixedPoint& operator=(const FixedPoint&) = default;
+
+    constexpr FixedPoint(FixedPoint&&) noexcept = default;
+    constexpr FixedPoint& operator=(FixedPoint&&) noexcept = default;
 
     template <IsArithmetic Number>
     constexpr FixedPoint(Number n) : data_(static_cast<base_type>(n * one)) {}