From ee7916538ccdfd34c5f4d3ba765a1e125e6c9d7a Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Sat, 2 Sep 2023 09:10:35 -0600 Subject: [PATCH] :rotating_light: Fix some clang-tidy issues --- include/safe/algorithm/irange.hpp | 13 ++- include/safe/array.hpp | 84 +++++++++++-------- include/safe/big_integer/detail/compare.hpp | 19 ++--- .../safe/big_integer/detail/multiplies.hpp | 4 +- include/safe/big_integer/detail/plus.hpp | 4 +- include/safe/big_integer/detail/shift.hpp | 8 +- include/safe/big_integer/detail/storage.hpp | 32 ++++--- .../big_integer/interface/big_integer.hpp | 6 +- include/safe/detail/function.hpp | 23 ++--- include/safe/dsl/abs.hpp | 5 +- include/safe/dsl/detail/eval_is_subset.hpp | 6 +- include/safe/dsl/detail/triint.hpp | 6 +- include/safe/dsl/is_equal.hpp | 6 +- include/safe/dsl/is_subset.hpp | 4 +- include/safe/dsl/is_superset.hpp | 4 +- include/safe/dsl/ival.hpp | 4 +- include/safe/dsl/mask.hpp | 6 +- include/safe/dsl/shift_right.hpp | 3 +- include/safe/dsl/union.hpp | 5 +- include/safe/iostream.hpp | 4 +- include/safe/match.hpp | 9 +- include/safe/object.hpp | 8 +- include/safe/var.hpp | 2 +- 23 files changed, 135 insertions(+), 130 deletions(-) diff --git a/include/safe/algorithm/irange.hpp b/include/safe/algorithm/irange.hpp index cd90b22..67b6a6a 100644 --- a/include/safe/algorithm/irange.hpp +++ b/include/safe/algorithm/irange.hpp @@ -21,7 +21,9 @@ template struct irange { constexpr iterator(irange const *parent, T value, bool end) : parent_{parent}, value_{value}, end_{end} {} - constexpr ret_t operator*() const { return unsafe_cast(value_); } + constexpr auto operator*() const -> ret_t { + return unsafe_cast(value_); + } constexpr auto operator++() { auto const new_unsafe_value = value_++; @@ -37,14 +39,11 @@ template struct irange { return *this; } - constexpr bool operator==(iterator rhs) { + constexpr auto operator==(iterator rhs) -> bool { if (end_) { return rhs.end_; - - } else { - return parent_ == rhs.parent_ && value_ == rhs.value_ && - !rhs.end_; } + return parent_ == rhs.parent_ && value_ == rhs.value_ && !rhs.end_; } }; @@ -62,4 +61,4 @@ template struct irange { this, end_.unsafe_value() - 1, true}; } }; -} // namespace safe \ No newline at end of file +} // namespace safe diff --git a/include/safe/array.hpp b/include/safe/array.hpp index 0e3ef78..c5bbda4 100644 --- a/include/safe/array.hpp +++ b/include/safe/array.hpp @@ -28,87 +28,97 @@ template struct array { // TODO: constructors template - constexpr array(Us... values) : storage({values...}) {} + constexpr explicit array(Us... values) : storage({values...}) {} - [[nodiscard]] constexpr reference - operator[](var> pos) { + [[nodiscard]] constexpr auto + operator[](var> pos) -> reference { return storage[pos.unsafe_value()]; } - [[nodiscard]] constexpr const_reference - operator[](var> pos) const { + [[nodiscard]] constexpr auto + operator[](var> pos) const -> const_reference { return storage[pos.unsafe_value()]; } - [[nodiscard]] constexpr reference - at(var> pos) { + [[nodiscard]] constexpr auto at(var> pos) + -> reference { return storage[pos.unsafe_value()]; } - [[nodiscard]] constexpr const_reference - at(var> pos) const { + [[nodiscard]] constexpr auto at(var> pos) const + -> const_reference { return storage[pos.unsafe_value()]; } - [[nodiscard]] constexpr reference front() { return storage.front(); } + [[nodiscard]] constexpr auto front() -> reference { + return storage.front(); + } - [[nodiscard]] constexpr const_reference front() const { + [[nodiscard]] constexpr auto front() const -> const_reference { return storage.front(); } - [[nodiscard]] constexpr reference back() { return storage.back(); } + [[nodiscard]] constexpr auto back() -> reference { return storage.back(); } - [[nodiscard]] constexpr const_reference back() const { + [[nodiscard]] constexpr auto back() const -> const_reference { return storage.back(); } // NOTE: intentionally omitting data() - [[nodiscard]] constexpr iterator begin() { return storage.begin(); } + [[nodiscard]] constexpr auto begin() -> iterator { return storage.begin(); } - [[nodiscard]] constexpr const_iterator begin() const { + [[nodiscard]] constexpr auto begin() const -> const_iterator { return storage.begin(); } - [[nodiscard]] constexpr const_iterator cbegin() const { + [[nodiscard]] constexpr auto cbegin() const -> const_iterator { return storage.cbegin(); } - [[nodiscard]] constexpr iterator end() { return storage.end(); } + [[nodiscard]] constexpr auto end() -> iterator { return storage.end(); } - [[nodiscard]] constexpr const_iterator end() const { return storage.end(); } + [[nodiscard]] constexpr auto end() const -> const_iterator { + return storage.end(); + } - [[nodiscard]] constexpr const_iterator cend() const { + [[nodiscard]] constexpr auto cend() const -> const_iterator { return storage.cend(); } - [[nodiscard]] constexpr reverse_iterator rbegin() { + [[nodiscard]] constexpr auto rbegin() -> reverse_iterator { return storage.rbegin(); } - [[nodiscard]] constexpr const_reverse_iterator rbegin() const { + [[nodiscard]] constexpr auto rbegin() const -> const_reverse_iterator { return storage.rbegin(); } - [[nodiscard]] constexpr const_reverse_iterator crbegin() const { + [[nodiscard]] constexpr auto crbegin() const -> const_reverse_iterator { return storage.crbegin(); } - [[nodiscard]] constexpr reverse_iterator rend() { return storage.rend(); } + [[nodiscard]] constexpr auto rend() -> reverse_iterator { + return storage.rend(); + } - [[nodiscard]] constexpr const_reverse_iterator rend() const { + [[nodiscard]] constexpr auto rend() const -> const_reverse_iterator { return storage.rend(); } - [[nodiscard]] constexpr const_reverse_iterator crend() const { + [[nodiscard]] constexpr auto crend() const -> const_reverse_iterator { return storage.crend(); } - [[nodiscard]] constexpr bool empty() const { return storage.empty(); } + [[nodiscard]] constexpr auto empty() const -> bool { + return storage.empty(); + } - [[nodiscard]] constexpr size_type size() const { return storage.size(); } + [[nodiscard]] constexpr auto size() const -> size_type { + return storage.size(); + } - [[nodiscard]] constexpr size_type max_size() const { + [[nodiscard]] constexpr auto max_size() const -> size_type { return storage.max_size(); } @@ -116,8 +126,8 @@ template struct array { constexpr void swap(array &other) { storage.swap(other.storage); } - [[nodiscard]] friend constexpr bool operator==(array const &lhs, - array const &rhs) { + [[nodiscard]] friend constexpr auto operator==(array const &lhs, + array const &rhs) -> bool { return lhs.storage == rhs.storage; } @@ -132,22 +142,24 @@ template array(T, U...) -> array; namespace std { template -[[nodiscard]] constexpr T &get(safe::array &a) noexcept { +[[nodiscard]] constexpr auto get(safe::array &a) noexcept -> T & { return a[safe::constant]; } template -[[nodiscard]] constexpr T &&get(safe::array &&a) noexcept { - return a[safe::constant]; +[[nodiscard]] constexpr auto get(safe::array &&a) noexcept -> T && { + return std::move(a)[safe::constant]; } template -[[nodiscard]] constexpr T const &get(safe::array const &a) noexcept { +[[nodiscard]] constexpr auto get(safe::array const &a) noexcept + -> T const & { return a[safe::constant]; } template -[[nodiscard]] constexpr T const &&get(safe::array const &&a) noexcept { +[[nodiscard]] constexpr auto get(safe::array const &&a) noexcept + -> T const && { return a[safe::constant]; } @@ -164,4 +176,4 @@ template struct tuple_element> { using type = T; }; -} // namespace std \ No newline at end of file +} // namespace std diff --git a/include/safe/big_integer/detail/compare.hpp b/include/safe/big_integer/detail/compare.hpp index 05d6167..c6ebb92 100644 --- a/include/safe/big_integer/detail/compare.hpp +++ b/include/safe/big_integer/detail/compare.hpp @@ -17,8 +17,8 @@ template if (lhs.get(i) < rhs.get(i)) { return std::strong_ordering::less; - - } else if (lhs.get(i) > rhs.get(i)) { + } + if (lhs.get(i) > rhs.get(i)) { return std::strong_ordering::greater; } } while (i > 0); @@ -33,15 +33,12 @@ template if (lhs.negative()) { if (rhs.negative()) { return unsigned_compare(lhs, rhs); - } else { - return std::strong_ordering::less; - } - } else { - if (rhs.negative()) { - return std::strong_ordering::greater; - } else { - return unsigned_compare(lhs, rhs); } + return std::strong_ordering::less; + } + if (rhs.negative()) { + return std::strong_ordering::greater; } + return unsigned_compare(lhs, rhs); } -} // namespace safe::_big_integer::detail \ No newline at end of file +} // namespace safe::_big_integer::detail diff --git a/include/safe/big_integer/detail/multiplies.hpp b/include/safe/big_integer/detail/multiplies.hpp index fe69271..3f81f44 100644 --- a/include/safe/big_integer/detail/multiplies.hpp +++ b/include/safe/big_integer/detail/multiplies.hpp @@ -21,7 +21,7 @@ constexpr static auto unsigned_multiplies = [](auto &result, auto const &lhs, result_t partial_product{ {static_cast(raw_partial_product & 0xffff'ffffu), - static_cast(raw_partial_product >> 32)}}; + static_cast(raw_partial_product >> 32u)}}; bit_shift_left(partial_product, partial_product, (i + j) * 32); @@ -59,4 +59,4 @@ constexpr static auto multiplies = [](auto &result, auto const &lhs, } } }; -} // namespace safe::_big_integer::detail \ No newline at end of file +} // namespace safe::_big_integer::detail diff --git a/include/safe/big_integer/detail/plus.hpp b/include/safe/big_integer/detail/plus.hpp index a2340c7..c64babc 100644 --- a/include/safe/big_integer/detail/plus.hpp +++ b/include/safe/big_integer/detail/plus.hpp @@ -13,7 +13,7 @@ constexpr static auto plus = double_elem_t const result = lhs + rhs + static_cast(carry); - carry = result >> 32; + carry = result >> 32u; return result & 0xffff'ffffu; }); @@ -29,4 +29,4 @@ constexpr static auto minus = [](auto &result, auto const &lhs, negate(negative_rhs, rhs); plus(result, lhs, negative_rhs); }; -} // namespace safe::_big_integer::detail \ No newline at end of file +} // namespace safe::_big_integer::detail diff --git a/include/safe/big_integer/detail/shift.hpp b/include/safe/big_integer/detail/shift.hpp index 2bba128..24f231c 100644 --- a/include/safe/big_integer/detail/shift.hpp +++ b/include/safe/big_integer/detail/shift.hpp @@ -33,9 +33,8 @@ constexpr static auto bit_shift_left = reverse_zip_transform([=](elem_t const upper, elem_t const lower) { if (bit_shift_amt == 0) { return upper; - } else { - return (upper << bit_shift_amt) | (lower >> (32 - bit_shift_amt)); } + return (upper << bit_shift_amt) | (lower >> (32 - bit_shift_amt)); })(result, lhs_shifted_upper, lhs_shifted_lower); }; @@ -63,9 +62,8 @@ constexpr static auto bit_shift_right = zip_transform([=](elem_t const upper, elem_t const lower) { if (bit_shift_amt == 0) { return lower; - } else { - return (upper << (32 - bit_shift_amt)) | (lower >> bit_shift_amt); } + return (upper << (32 - bit_shift_amt)) | (lower >> bit_shift_amt); })(result, lhs_shifted_upper, lhs_shifted_lower); }; -} // namespace safe::_big_integer::detail \ No newline at end of file +} // namespace safe::_big_integer::detail diff --git a/include/safe/big_integer/detail/storage.hpp b/include/safe/big_integer/detail/storage.hpp index b95dae0..94b954d 100644 --- a/include/safe/big_integer/detail/storage.hpp +++ b/include/safe/big_integer/detail/storage.hpp @@ -19,10 +19,8 @@ template struct storage { std::array elems{}; constexpr storage() = default; - - constexpr storage(std::array const &new_elems) { - elems = new_elems; - } + constexpr storage(std::array const &new_elems) + : elems{new_elems} {} template constexpr storage(storage const &rhs) { @@ -51,22 +49,21 @@ template struct storage { return true; } - [[nodiscard]] constexpr bool negative() const { + [[nodiscard]] constexpr auto negative() const -> bool { return (elems.back() >> 31) & 1; } [[nodiscard]] constexpr auto get(int32_t i) const -> elem_t { if (i < 0) { return 0u; - } else if (i < num_elems) { + } + if (i < num_elems) { return elems[i]; - } else { - if (negative()) { - return 0xffff'ffffu; - } else { - return 0u; - } } + if (negative()) { + return 0xffff'ffffu; + } + return 0u; } constexpr auto set(int32_t i, elem_t elem) -> void { @@ -101,18 +98,19 @@ template } template -[[nodiscard]] constexpr auto const & -to_storage(interface::big_integer const &v) { +[[nodiscard]] constexpr auto +to_storage(interface::big_integer const &v) -> auto const & { return v.unsafe_storage; } template -[[nodiscard]] constexpr auto &to_storage(storage &v) { +[[nodiscard]] constexpr auto to_storage(storage &v) -> auto & { return v; } template -[[nodiscard]] constexpr auto const &to_storage(storage const &v) { +[[nodiscard]] constexpr auto to_storage(storage const &v) + -> auto const & { return v; } @@ -167,4 +165,4 @@ constexpr static auto sum_width = [](std::size_t left_bits, std::size_t right_bits) -> std::size_t { return left_bits + right_bits; }; -} // namespace safe::_big_integer::detail \ No newline at end of file +} // namespace safe::_big_integer::detail diff --git a/include/safe/big_integer/interface/big_integer.hpp b/include/safe/big_integer/interface/big_integer.hpp index 5c3d052..6b85974 100644 --- a/include/safe/big_integer/interface/big_integer.hpp +++ b/include/safe/big_integer/interface/big_integer.hpp @@ -10,11 +10,11 @@ namespace safe::_big_integer::interface { template struct big_integer { - detail::storage unsafe_storage; + detail::storage unsafe_storage{}; constexpr big_integer(auto value) : unsafe_storage{detail::to_storage(value)} {} - constexpr big_integer() : unsafe_storage{} {} + constexpr big_integer() = default; constexpr auto operator&=(auto const &rhs) -> big_integer & { return do_assign_op(detail::bit_and, rhs); @@ -386,4 +386,4 @@ struct std::numeric_limits< constexpr static auto signaling_NaN() noexcept -> T { return T{0}; } constexpr static auto denorm_min() noexcept -> T { return T{0}; } -}; \ No newline at end of file +}; diff --git a/include/safe/detail/function.hpp b/include/safe/detail/function.hpp index 2410dbd..b0b7b03 100644 --- a/include/safe/detail/function.hpp +++ b/include/safe/detail/function.hpp @@ -8,17 +8,17 @@ namespace safe::detail { using namespace boost::mp11; template struct runtime { - [[nodiscard]] constexpr static bool check(InputT) { return true; } + [[nodiscard]] constexpr static auto check(InputT) -> bool { return true; } }; template struct runtime { - [[nodiscard]] constexpr static bool check(InputT const &input) { + [[nodiscard]] constexpr static auto check(InputT const &input) -> bool { return VarT::requirement.check(input); } }; template struct runtime { - [[nodiscard]] constexpr static bool check(InputVarT const &input) { + [[nodiscard]] constexpr static auto check(InputVarT const &input) -> bool { if constexpr (VarT::requirement >= InputVarT::requirement) { return true; } else { @@ -28,21 +28,21 @@ template struct runtime { }; template -[[nodiscard]] constexpr bool check(ValueT value) { +[[nodiscard]] constexpr auto check(ValueT value) -> bool { return detail::runtime::check(value); } template -ReturnT ret_helper(ReturnT (T::*)(ArgTs...)); +auto ret_helper(ReturnT (T::*)(ArgTs...)) -> ReturnT; template -ReturnT ret_helper(ReturnT (T::*)(ArgTs...) const); +auto ret_helper(ReturnT (T::*)(ArgTs...) const) -> ReturnT; template -mp_list args_helper(ReturnT (T::*)(ArgTs...)); +auto args_helper(ReturnT (T::*)(ArgTs...)) -> mp_list; template -mp_list args_helper(ReturnT (T::*)(ArgTs...) const); +auto args_helper(ReturnT (T::*)(ArgTs...) const) -> mp_list; template struct function_info { using ret = decltype(ret_helper(&F::operator())); @@ -66,15 +66,16 @@ template using function_args_t = typename function_info::args; template using function_ret_t = typename function_info::ret; template -constexpr bool check(mp_list, ArgTs... args) { +constexpr auto check(mp_list, ArgTs... args) -> bool { return (check(args) && ...); } -template [[nodiscard]] constexpr decltype(auto) unwrap_var(T &&v) { +template +[[nodiscard]] constexpr auto unwrap_var(T &&v) -> decltype(auto) { if constexpr (Var>) { return v.unsafe_value(); } else { return std::forward(v); } } -} // namespace safe::detail \ No newline at end of file +} // namespace safe::detail diff --git a/include/safe/dsl/abs.hpp b/include/safe/dsl/abs.hpp index f78e2da..f25ddb4 100644 --- a/include/safe/dsl/abs.hpp +++ b/include/safe/dsl/abs.hpp @@ -12,9 +12,8 @@ namespace detail { [[nodiscard]] constexpr auto abs(auto value) { if (value < 0) { return -value; - } else { - return decltype(-value){value}; } + return decltype(-value){value}; } } // namespace detail @@ -34,4 +33,4 @@ template struct abs_t : public detail::unary_op { template [[nodiscard]] constexpr auto abs(T) -> abs_t { return {}; } -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/detail/eval_is_subset.hpp b/include/safe/dsl/detail/eval_is_subset.hpp index a493a93..0610279 100644 --- a/include/safe/dsl/detail/eval_is_subset.hpp +++ b/include/safe/dsl/detail/eval_is_subset.hpp @@ -10,14 +10,14 @@ template struct all_of { using type = all_of; constexpr static bool value = (eval_t::value && ...); - [[nodiscard]] constexpr operator bool() const { return value; } + [[nodiscard]] constexpr explicit operator bool() const { return value; } }; template struct any_of { using type = any_of; constexpr static bool value = (eval_t::value || ...); - [[nodiscard]] constexpr operator bool() const { return value; } + [[nodiscard]] constexpr explicit operator bool() const { return value; } }; template @@ -37,4 +37,4 @@ struct eval, std::enable_if_t && !is_union_v && (!is_primitive_v || !is_primitive_v)>> : public eval_t, eval_t>> {}; -} // namespace safe::dsl::detail \ No newline at end of file +} // namespace safe::dsl::detail diff --git a/include/safe/dsl/detail/triint.hpp b/include/safe/dsl/detail/triint.hpp index d070f8c..4f31e4d 100644 --- a/include/safe/dsl/detail/triint.hpp +++ b/include/safe/dsl/detail/triint.hpp @@ -19,9 +19,9 @@ template struct triint { constexpr triint(T var_bits, T const_bits) : var_bits_{var_bits}, const_bits_{const_bits & ~var_bits} {} - [[nodiscard]] constexpr T var_bits() const { return var_bits_; } + [[nodiscard]] constexpr auto var_bits() const -> T { return var_bits_; } - [[nodiscard]] constexpr T const_bits() const { return const_bits_; } + [[nodiscard]] constexpr auto const_bits() const -> T { return const_bits_; } }; template @@ -113,4 +113,4 @@ template template triint(T var_bits, U const_bits) -> triint>; -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/is_equal.hpp b/include/safe/dsl/is_equal.hpp index 122f4d3..7a58519 100644 --- a/include/safe/dsl/is_equal.hpp +++ b/include/safe/dsl/is_equal.hpp @@ -7,7 +7,7 @@ namespace safe::dsl { template -[[nodiscard]] constexpr bool operator==(LhsT lhs, RhsT rhs) { +[[nodiscard]] constexpr auto operator==(LhsT lhs, RhsT rhs) -> bool { auto const simp_lhs = detail::simp(lhs); auto const simp_rhs = detail::simp(rhs); @@ -15,7 +15,7 @@ template } template -[[nodiscard]] constexpr bool operator!=(LhsT lhs, RhsT rhs) { +[[nodiscard]] constexpr auto operator!=(LhsT lhs, RhsT rhs) -> bool { return !(lhs == rhs); } -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/is_subset.hpp b/include/safe/dsl/is_subset.hpp index 90576a9..154ecf0 100644 --- a/include/safe/dsl/is_subset.hpp +++ b/include/safe/dsl/is_subset.hpp @@ -67,7 +67,7 @@ struct is_subset, }; template -[[nodiscard]] constexpr bool operator<=(LhsT, RhsT) { +[[nodiscard]] constexpr auto operator<=(LhsT, RhsT) -> bool { return detail::eval_v>; } -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/is_superset.hpp b/include/safe/dsl/is_superset.hpp index 6d694c1..a65a4a6 100644 --- a/include/safe/dsl/is_superset.hpp +++ b/include/safe/dsl/is_superset.hpp @@ -8,7 +8,7 @@ namespace safe::dsl { template using is_superset = is_subset; template -[[nodiscard]] constexpr bool operator>=(LhsT, RhsT) { +[[nodiscard]] constexpr auto operator>=(LhsT, RhsT) -> bool { return detail::eval_v>; } -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/ival.hpp b/include/safe/dsl/ival.hpp index 9f5ddd0..dd42a7e 100644 --- a/include/safe/dsl/ival.hpp +++ b/include/safe/dsl/ival.hpp @@ -15,7 +15,7 @@ template struct ival_t : public detail::primitive { // static_assert(min <= max); - [[nodiscard]] SAFE_PURE constexpr static bool check(auto value) { + [[nodiscard]] SAFE_PURE constexpr static auto check(auto value) -> bool { return value >= min && value <= max; } }; @@ -29,4 +29,4 @@ template constexpr bool is_ival_v> = true; template concept Interval = is_ival_v; -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/mask.hpp b/include/safe/dsl/mask.hpp index 4ac84eb..fd2dcab 100644 --- a/include/safe/dsl/mask.hpp +++ b/include/safe/dsl/mask.hpp @@ -18,7 +18,7 @@ struct mask_t : public detail::primitive { constexpr static auto const_bits = ConstantBits; constexpr static auto value = triint{var_bits, const_bits}; - [[nodiscard]] SAFE_PURE constexpr static bool check(auto value) { + [[nodiscard]] SAFE_PURE constexpr static auto check(auto value) -> bool { return (~var_bits & value) == (~var_bits & const_bits); } }; @@ -65,7 +65,7 @@ template struct to_ival> { template using to_ival_t = typename to_ival::type; -[[nodiscard]] constexpr bool is_basic_mask(auto value) { +[[nodiscard]] constexpr auto is_basic_mask(auto value) -> bool { return ((value >> 1) & value) == (value >> 1); } @@ -92,4 +92,4 @@ constexpr bool is_mask_v> = true; template concept Mask = is_mask_v; -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/shift_right.hpp b/include/safe/dsl/shift_right.hpp index a663a82..76c16aa 100644 --- a/include/safe/dsl/shift_right.hpp +++ b/include/safe/dsl/shift_right.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -41,4 +42,4 @@ template [[nodiscard]] constexpr auto operator>>(LhsT, RhsT) -> shift_right { return {}; } -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/dsl/union.hpp b/include/safe/dsl/union.hpp index 1ed83c3..9d2a58a 100644 --- a/include/safe/dsl/union.hpp +++ b/include/safe/dsl/union.hpp @@ -1,13 +1,14 @@ #pragma once #include +#include namespace safe::dsl { template struct union_t : public detail::set_op { using type = union_t; template - [[nodiscard]] SAFE_PURE constexpr static bool check(T value) { + [[nodiscard]] SAFE_PURE constexpr static auto check(T value) -> bool { return (Intervals::check(value) || ...); } }; @@ -16,4 +17,4 @@ template [[nodiscard]] constexpr auto operator||(LhsT, RhsT) -> union_t { return {}; } -} // namespace safe::dsl \ No newline at end of file +} // namespace safe::dsl diff --git a/include/safe/iostream.hpp b/include/safe/iostream.hpp index dc77487..f98b169 100644 --- a/include/safe/iostream.hpp +++ b/include/safe/iostream.hpp @@ -3,6 +3,6 @@ #include #include -std::ostream &operator<<(std::ostream &os, safe::Var auto var) { +auto operator<<(std::ostream &os, safe::Var auto var) -> std::ostream & { return os << var.unsafe_value(); -} \ No newline at end of file +} diff --git a/include/safe/match.hpp b/include/safe/match.hpp index a2d8f9c..bd1029a 100644 --- a/include/safe/match.hpp +++ b/include/safe/match.hpp @@ -74,11 +74,10 @@ template return func(unsafe_cast_ferry{ detail::unwrap_var(std::forward(args))}...); - } else { // check the remaining functions' requirements - return match(remaining_funcs...)( - std::forward(args)...); - } + } // check the remaining functions' requirements + return match(remaining_funcs...)( + std::forward(args)...); } }; } -} // namespace safe \ No newline at end of file +} // namespace safe diff --git a/include/safe/object.hpp b/include/safe/object.hpp index b34d7e1..015453a 100644 --- a/include/safe/object.hpp +++ b/include/safe/object.hpp @@ -4,15 +4,15 @@ namespace safe { template struct object { T value; - [[nodiscard]] T *operator->() { return &value; } + [[nodiscard]] auto operator->() -> T * { return &value; } - [[nodiscard]] T &operator*() { return value; } + [[nodiscard]] auto operator*() -> T & { return value; } }; template struct field_t { - constexpr bool operator&&(auto) const { return false; } + constexpr auto operator&&(auto) const -> bool { return false; } }; template constexpr auto field = field_t{}; -} // namespace safe \ No newline at end of file +} // namespace safe diff --git a/include/safe/var.hpp b/include/safe/var.hpp index 7c43db1..a38b76d 100644 --- a/include/safe/var.hpp +++ b/include/safe/var.hpp @@ -69,7 +69,7 @@ template struct var { return *this; } - [[nodiscard]] SAFE_INLINE constexpr T unsafe_value() const { + [[nodiscard]] SAFE_INLINE constexpr auto unsafe_value() const -> T { SAFE_ASSUME(requirement.check(unsafe_value_)); return unsafe_value_; }