summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-03-02 18:20:39 +0000
committerArne Juul <arnej@verizonmedia.com>2021-03-02 18:20:39 +0000
commitd537d7c2fb18a2694a31b815a5e82ea69e102599 (patch)
tree42919af2d15f0ce3a12967b08d170d7c6676e510
parent8521832abb54bf3cf3431020da6bc400366dc610 (diff)
make the tricky stuff private
-rw-r--r--vespalib/src/vespa/vespalib/util/bfloat16.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/vespalib/src/vespa/vespalib/util/bfloat16.h b/vespalib/src/vespa/vespalib/util/bfloat16.h
index f5066d2f8e5..81c1bc5bcba 100644
--- a/vespalib/src/vespa/vespalib/util/bfloat16.h
+++ b/vespalib/src/vespa/vespalib/util/bfloat16.h
@@ -25,26 +25,6 @@ private:
uint16_t u1;
uint16_t u2;
};
-public:
- constexpr BFloat16(float value) noexcept : _bits(float_to_bits(value)) {}
- BFloat16() noexcept = default;
- ~BFloat16() noexcept = default;
- constexpr BFloat16(const BFloat16 &other) noexcept = default;
- constexpr BFloat16(BFloat16 &&other) noexcept = default;
- constexpr BFloat16& operator=(const BFloat16 &other) noexcept = default;
- constexpr BFloat16& operator=(BFloat16 &&other) noexcept = default;
- constexpr BFloat16& operator=(float value) noexcept {
- _bits = float_to_bits(value);
- return *this;
- }
-
- constexpr operator float () const noexcept { return bits_to_float(_bits); }
-
- constexpr float to_float() const noexcept { return bits_to_float(_bits); }
- constexpr void assign(float value) noexcept { _bits = float_to_bits(value); }
-
- constexpr uint16_t get_bits() const { return _bits; }
- constexpr void assign_bits(uint16_t value) noexcept { _bits = value; }
template<std::endian native_endian = std::endian::native>
static constexpr uint16_t float_to_bits(float value) noexcept {
@@ -75,6 +55,26 @@ public:
memcpy(&result, &both, sizeof(float));
return result;
}
+public:
+ constexpr BFloat16(float value) noexcept : _bits(float_to_bits(value)) {}
+ BFloat16() noexcept = default;
+ ~BFloat16() noexcept = default;
+ constexpr BFloat16(const BFloat16 &other) noexcept = default;
+ constexpr BFloat16(BFloat16 &&other) noexcept = default;
+ constexpr BFloat16& operator=(const BFloat16 &other) noexcept = default;
+ constexpr BFloat16& operator=(BFloat16 &&other) noexcept = default;
+ constexpr BFloat16& operator=(float value) noexcept {
+ _bits = float_to_bits(value);
+ return *this;
+ }
+
+ constexpr operator float () const noexcept { return bits_to_float(_bits); }
+
+ constexpr float to_float() const noexcept { return bits_to_float(_bits); }
+ constexpr void assign(float value) noexcept { _bits = float_to_bits(value); }
+
+ constexpr uint16_t get_bits() const { return _bits; }
+ constexpr void assign_bits(uint16_t value) noexcept { _bits = value; }
};
}