Skip to content

Commit

Permalink
🔨 Modernize math sources/headers
Browse files Browse the repository at this point in the history
The various math headers and sources have been modernized using
`clang-tidy` and cleaned up with a post-processing pass.
  • Loading branch information
bitwizeshift committed Sep 6, 2020
1 parent 7b2885b commit 2479dc8
Show file tree
Hide file tree
Showing 12 changed files with 929 additions and 952 deletions.
333 changes: 164 additions & 169 deletions lib/alloy-core/include/alloy/core/math/angle/basic_angle.hpp

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions lib/alloy-core/include/alloy/core/math/angle/degree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace alloy::core {

struct degree_unit
{
static constexpr core::real revolution() noexcept;
static constexpr auto revolution() noexcept -> core::real;
};

//============================================================================
Expand All @@ -72,7 +72,7 @@ namespace alloy::core {
/// \param angle the angle to convert
/// \return the angle in degrees
template<typename AngleUnit>
constexpr degree to_degree( basic_angle<AngleUnit> angle ) noexcept;
constexpr auto to_degree(basic_angle<AngleUnit> angle) noexcept -> degree;

} // inline namespace casts

Expand Down Expand Up @@ -105,7 +105,7 @@ namespace alloy::core {
//============================================================================

inline namespace literals {
constexpr degree operator""_deg( long double x ) noexcept;
constexpr auto operator""_deg(long double x) noexcept -> degree;
} // inline namespace literals
} // namespace alloy::core

Expand All @@ -114,8 +114,8 @@ namespace alloy::core {
// struct : degree_unit
//==============================================================================

inline constexpr alloy::core::real alloy::core::degree_unit::revolution()
noexcept
inline constexpr auto
alloy::core::degree_unit::revolution() noexcept -> alloy::core::real
{
return static_cast<real>(360);
}
Expand All @@ -129,9 +129,9 @@ inline constexpr alloy::core::real alloy::core::degree_unit::revolution()
//------------------------------------------------------------------------------

template<typename AngleUnit>
inline constexpr alloy::core::degree
alloy::core::casts::to_degree( basic_angle<AngleUnit> angle )
noexcept
inline constexpr auto
alloy::core::casts::to_degree(basic_angle<AngleUnit> angle) noexcept
-> alloy::core::degree
{
return to_angle<degree>(angle);
}
Expand All @@ -140,9 +140,9 @@ inline constexpr alloy::core::degree
// Literals
//==============================================================================

inline constexpr alloy::core::degree
alloy::core::literals::operator ""_deg( long double x )
noexcept
inline constexpr auto
alloy::core::literals::operator""_deg(long double x) noexcept
-> alloy::core::degree
{
return degree{ static_cast<real>(x) };
}
Expand Down
25 changes: 13 additions & 12 deletions lib/alloy-core/include/alloy/core/math/angle/gradian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace alloy::core {

struct gradian_unit
{
static constexpr core::real revolution() noexcept;
static constexpr auto revolution() noexcept -> real;
};

//============================================================================
Expand All @@ -72,7 +72,7 @@ namespace alloy::core {
/// \param angle the angle to convert
/// \return the angle in gradians
template<typename AngleUnit>
constexpr gradian to_gradian( basic_angle<AngleUnit> angle ) noexcept;
constexpr auto to_gradian(basic_angle<AngleUnit> angle) noexcept -> gradian;

} // inline namespace casts

Expand Down Expand Up @@ -105,7 +105,7 @@ namespace alloy::core {
//============================================================================

inline namespace literals {
constexpr gradian operator""_grad( long double x ) noexcept;
constexpr auto operator""_grad(long double x) noexcept -> gradian;
} // inline namespace literals
} // namespace alloy::core

Expand All @@ -114,8 +114,9 @@ namespace alloy::core {
// struct : gradian_unit
//==============================================================================

inline constexpr alloy::core::real alloy::core::gradian_unit::revolution()
noexcept
inline constexpr
auto alloy::core::gradian_unit::revolution()
noexcept -> real
{
return static_cast<real>(400);
}
Expand All @@ -129,9 +130,9 @@ inline constexpr alloy::core::real alloy::core::gradian_unit::revolution()
//------------------------------------------------------------------------------

template<typename AngleUnit>
inline constexpr alloy::core::gradian
alloy::core::casts::to_gradian( basic_angle<AngleUnit> angle )
noexcept
inline constexpr
auto alloy::core::casts::to_gradian(basic_angle<AngleUnit> angle)
noexcept -> gradian
{
return to_angle<gradian>(angle);
}
Expand All @@ -140,11 +141,11 @@ inline constexpr alloy::core::gradian
// Literals
//==============================================================================

inline constexpr alloy::core::gradian
alloy::core::literals::operator ""_grad( long double x )
noexcept
inline constexpr
auto alloy::core::literals::operator""_grad(long double x)
noexcept -> gradian
{
return gradian{ static_cast<real>(x) };
}

#endif /* ALLOY_CORE_MATH_ANGLE_GRADIAN_HPP */
#endif /* ALLOY_CORE_MATH_ANGLE_GRADIAN_HPP */
23 changes: 12 additions & 11 deletions lib/alloy-core/include/alloy/core/math/angle/radian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace alloy::core {

struct radian_unit
{
static constexpr core::real revolution() noexcept;
static constexpr auto revolution() noexcept -> real;
};

//============================================================================
Expand All @@ -73,7 +73,7 @@ namespace alloy::core {
/// \param angle the angle to convert
/// \return the angle in radians
template<typename AngleUnit>
constexpr radian to_radian( basic_angle<AngleUnit> angle ) noexcept;
constexpr auto to_radian(basic_angle<AngleUnit> angle) noexcept -> radian;

} // inline namespace casts

Expand Down Expand Up @@ -106,7 +106,7 @@ namespace alloy::core {
//============================================================================

inline namespace literals {
constexpr radian operator""_rad( long double x ) noexcept;
constexpr auto operator""_rad(long double x) noexcept -> radian;
} // inline namespace literals
} // namespace alloy::core

Expand All @@ -115,8 +115,9 @@ namespace alloy::core {
// struct : radian_unit
//==============================================================================

inline constexpr alloy::core::real alloy::core::radian_unit::revolution()
noexcept
inline constexpr
auto alloy::core::radian_unit::revolution()
noexcept -> real
{
return static_cast<real>(math_constants::two_pi);
}
Expand All @@ -130,9 +131,9 @@ inline constexpr alloy::core::real alloy::core::radian_unit::revolution()
//------------------------------------------------------------------------------

template<typename AngleUnit>
inline constexpr alloy::core::radian
alloy::core::casts::to_radian( basic_angle<AngleUnit> angle )
noexcept
inline constexpr
auto alloy::core::casts::to_radian(basic_angle<AngleUnit> angle)
noexcept -> radian
{
return to_angle<radian>(angle);
}
Expand All @@ -141,9 +142,9 @@ inline constexpr alloy::core::radian
// Literals
//==============================================================================

inline constexpr alloy::core::radian
alloy::core::literals::operator ""_rad( long double x )
noexcept
inline constexpr
auto alloy::core::literals::operator""_rad(long double x)
noexcept -> radian
{
return radian{ static_cast<real>(x) };
}
Expand Down
Loading

0 comments on commit 2479dc8

Please sign in to comment.