mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 14:49:53 +08:00
Added inline namespaces
Added missing comparison operators Replaced 'typedef' with 'using'
This commit is contained in:
parent
a0d81170c8
commit
c78b5ca76a
@ -171,9 +171,9 @@ namespace etl
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare day with another.
|
||||
/// if day < other, returns -1;
|
||||
/// else if day > other, returns 1;
|
||||
/// else returns 0;
|
||||
/// if day < other, returns -1
|
||||
/// else if day > other, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const day& other) const ETL_NOEXCEPT
|
||||
@ -336,9 +336,9 @@ namespace etl
|
||||
#if ETL_HAS_CHRONO_LITERALS_DAY
|
||||
namespace etl
|
||||
{
|
||||
namespace literals
|
||||
inline namespace literals
|
||||
{
|
||||
namespace chrono_literals
|
||||
inline namespace chrono_literals
|
||||
{
|
||||
#if ETL_USING_VERBOSE_CHRONO_LITERALS
|
||||
inline ETL_CONSTEXPR14 etl::chrono::day operator ""_day(unsigned long long d) noexcept
|
||||
|
||||
@ -106,8 +106,8 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TRep rep;
|
||||
typedef typename TPeriod::type period;
|
||||
using rep = TRep;
|
||||
using period = typename TPeriod::type;
|
||||
|
||||
//***********************************************************************
|
||||
ETL_CONSTEXPR duration() ETL_NOEXCEPT
|
||||
@ -285,9 +285,9 @@ namespace etl
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare duration with another.
|
||||
/// if duration < other, returns -1;
|
||||
/// else if duration > other, returns 1;
|
||||
/// else returns 0;
|
||||
/// if duration < other, returns -1
|
||||
/// else if duration > other, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
template <typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14 int compare(const duration<TRep2, TPeriod2>& other) const ETL_NOEXCEPT
|
||||
@ -313,22 +313,22 @@ namespace etl
|
||||
/// Duration types
|
||||
//***********************************************************************
|
||||
#if (ETL_USING_64BIT_TYPES)
|
||||
typedef etl::chrono::duration<int64_t, etl::nano> nanoseconds;
|
||||
typedef etl::chrono::duration<int64_t, etl::micro> microseconds;
|
||||
typedef etl::chrono::duration<int64_t, etl::milli> milliseconds;
|
||||
typedef etl::chrono::duration<int64_t, etl::ratio<1U> > seconds;
|
||||
using nanoseconds = etl::chrono::duration<int64_t, etl::nano>;
|
||||
using microseconds = etl::chrono::duration<int64_t, etl::micro>;
|
||||
using milliseconds = etl::chrono::duration<int64_t, etl::milli>;
|
||||
using seconds = etl::chrono::duration<int64_t, etl::ratio<1U>>;
|
||||
#else
|
||||
typedef etl::chrono::duration<int32_t, etl::nano> nanoseconds;
|
||||
typedef etl::chrono::duration<int32_t, etl::micro> microseconds;
|
||||
typedef etl::chrono::duration<int32_t, etl::milli> milliseconds;
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<1U> > seconds;
|
||||
using nanoseconds = etl::chrono::duration<int32_t, etl::nano>;
|
||||
using microseconds = etl::chrono::duration<int32_t, etl::micro>;
|
||||
using milliseconds = etl::chrono::duration<int32_t, etl::milli>;
|
||||
using seconds = etl::chrono::duration<int32_t, etl::ratio<1U>>;
|
||||
#endif
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<60U> > minutes;
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<3600U> > hours;
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<86400U> > days;
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<604800U> > weeks;
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<2629746U> > months;
|
||||
typedef etl::chrono::duration<int32_t, etl::ratio<31556952U> > years;
|
||||
using minutes = etl::chrono::duration<int32_t, etl::ratio<60U>>;
|
||||
using hours = etl::chrono::duration<int32_t, etl::ratio<3600U>>;
|
||||
using days = etl::chrono::duration<int32_t, etl::ratio<86400U>>;
|
||||
using weeks = etl::chrono::duration<int32_t, etl::ratio<604800U>>;
|
||||
using months = etl::chrono::duration<int32_t, etl::ratio<2629746U>>;
|
||||
using years = etl::chrono::duration<int32_t, etl::ratio<31556952U>>;
|
||||
|
||||
//***********************************************************************
|
||||
/// duration_cast
|
||||
@ -336,14 +336,14 @@ namespace etl
|
||||
template <typename TToDuration, typename TRep, typename TPeriod>
|
||||
ETL_CONSTEXPR14 TToDuration duration_cast(const etl::chrono::duration<TRep, TPeriod>& d) ETL_NOEXCEPT
|
||||
{
|
||||
typedef TRep from_rep;
|
||||
typedef TPeriod from_period;
|
||||
using from_rep = TRep ;
|
||||
using from_period = TPeriod ;
|
||||
|
||||
typedef typename TToDuration::rep to_rep;
|
||||
typedef typename TToDuration::period to_period;
|
||||
using to_rep = typename TToDuration::rep;
|
||||
using to_period = typename TToDuration::period;
|
||||
|
||||
typedef typename etl::ratio_divide<from_period, to_period> ratio_divide_t;
|
||||
typedef typename etl::common_type<from_rep, to_rep, intmax_t>::type common_t;
|
||||
using ratio_divide_t = typename etl::ratio_divide<from_period, to_period>;
|
||||
using common_t = typename etl::common_type<from_rep, to_rep, intmax_t>::type;
|
||||
|
||||
common_t ct_count = static_cast<common_t>(d.count());
|
||||
common_t ct_num = static_cast<common_t>(ratio_divide_t::type::num);
|
||||
@ -396,13 +396,13 @@ namespace etl
|
||||
/// Find the common type of two duration types.
|
||||
//***********************************************************************
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
struct common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >
|
||||
struct common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2>>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename etl::common_type<TRep1, TRep2>::type value_type;
|
||||
typedef etl::ratio<etl::chrono::private_chrono::gcd<TPeriod1::num, TPeriod2::num>::value,
|
||||
etl::chrono::private_chrono::lcm<TPeriod1::den, TPeriod2::den>::value> period_type;
|
||||
using value_type = typename etl::common_type<TRep1, TRep2>::type ;
|
||||
using period_type = etl::ratio<etl::chrono::private_chrono::gcd<TPeriod1::num, TPeriod2::num>::value,
|
||||
etl::chrono::private_chrono::lcm<TPeriod1::den, TPeriod2::den>::value>;
|
||||
|
||||
public:
|
||||
|
||||
@ -416,7 +416,7 @@ namespace etl
|
||||
ETL_CONSTEXPR14 bool operator ==(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
typedef typename etl::common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >::type common_t;
|
||||
using common_t = typename etl::common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >::type;
|
||||
|
||||
common_t l = etl::chrono::duration_cast<common_t>(lhs);
|
||||
common_t r = etl::chrono::duration_cast<common_t>(rhs);
|
||||
@ -441,7 +441,7 @@ namespace etl
|
||||
ETL_CONSTEXPR14 bool operator <(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
typedef typename etl::common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >::type common_t;
|
||||
using common_t = typename etl::common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >::type;
|
||||
|
||||
common_t l = etl::chrono::duration_cast<common_t>(lhs);
|
||||
common_t r = etl::chrono::duration_cast<common_t>(rhs);
|
||||
@ -487,7 +487,7 @@ namespace etl
|
||||
[[nodiscard]] constexpr auto operator <=>(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
typedef typename etl::common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >::type common_t;
|
||||
using common_t = typename etl::common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2> >::type;
|
||||
|
||||
common_t l = etl::chrono::duration_cast<common_t>(lhs);
|
||||
common_t r = etl::chrono::duration_cast<common_t>(rhs);
|
||||
@ -709,9 +709,9 @@ namespace etl
|
||||
#if ETL_HAS_CHRONO_LITERALS_DURATION
|
||||
namespace etl
|
||||
{
|
||||
namespace literals
|
||||
inline namespace literals
|
||||
{
|
||||
namespace chrono_literals
|
||||
inline namespace chrono_literals
|
||||
{
|
||||
//***********************************************************************
|
||||
/// Literal for hours duration
|
||||
|
||||
@ -44,7 +44,6 @@ namespace etl
|
||||
template <typename TDuration>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
//typename etl::enable_if<etl::chrono::is_duration<TDuration>::value, TDuration>::type
|
||||
typename etl::enable_if<etl::is_specialization<TDuration, etl::chrono::duration>::value, TDuration>::type
|
||||
absolute(TDuration dur) ETL_NOEXCEPT
|
||||
{
|
||||
|
||||
@ -165,9 +165,9 @@ namespace etl
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare month with another.
|
||||
/// if month < other, returns -1;
|
||||
/// else if month > other, returns 1;
|
||||
/// else returns 0;
|
||||
/// if month < other, returns -1
|
||||
/// else if month > other, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const month& other) const ETL_NOEXCEPT
|
||||
@ -367,68 +367,6 @@ namespace etl
|
||||
static ETL_CONSTANT etl::chrono::month November{ 11 };
|
||||
static ETL_CONSTANT etl::chrono::month December{ 12 };
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// month_day_last
|
||||
//*************************************************************************
|
||||
class month_day_last
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from month.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 explicit month_day_last(const etl::chrono::month& m_) ETL_NOEXCEPT
|
||||
: m(m_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get the month.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
|
||||
{
|
||||
return m;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Is the contained month OK?
|
||||
//*************************************************************************
|
||||
bool ok() const ETL_NOEXCEPT
|
||||
{
|
||||
return m.ok();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::chrono::month m;
|
||||
};
|
||||
|
||||
//***********************************************************************
|
||||
/// Equality operator
|
||||
//***********************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_day_last& mdl1, const etl::chrono::month_day_last& mdl2) ETL_NOEXCEPT
|
||||
{
|
||||
return (static_cast<unsigned>(mdl1.month()) == static_cast<unsigned>(mdl2.month()));
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Inequality operator
|
||||
//***********************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_day_last& mdl1, const etl::chrono::month_day_last& mdl2) ETL_NOEXCEPT
|
||||
{
|
||||
return !(mdl1 == mdl2);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] inline constexpr auto operator <=>(const etl::chrono::month_day_last& mdl1, const etl::chrono::month_day_last& mdl2) noexcept
|
||||
{
|
||||
return (static_cast<unsigned>(mdl1.month()) <=> static_cast<unsigned>(mdl2.month()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -448,20 +386,5 @@ namespace etl
|
||||
};
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function for etl::chrono::month_day_last
|
||||
//*************************************************************************
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
template <>
|
||||
struct hash<etl::chrono::month_day_last>
|
||||
{
|
||||
size_t operator()(const etl::chrono::month_day_last& mdl) const
|
||||
{
|
||||
etl::chrono::month::rep value = static_cast<etl::chrono::month::rep>(static_cast<unsigned>(mdl.month()));
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(&value);
|
||||
|
||||
return etl::private_hash::generic_hash<size_t>(p, p + sizeof(value));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -94,102 +94,13 @@ namespace etl
|
||||
(static_cast<unsigned>(d) <= max_day);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.d == rhs.d) && (lhs.m == rhs.m);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD friend ETL_CONSTEXPR14
|
||||
bool operator <(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
if (lhs.month() < rhs.month())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lhs.month() == rhs.month())
|
||||
{
|
||||
return lhs.day() < rhs.day();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD friend ETL_CONSTEXPR14
|
||||
bool operator <=(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD friend ETL_CONSTEXPR14
|
||||
bool operator >(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD friend ETL_CONSTEXPR14
|
||||
bool operator >=(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) noexcept
|
||||
{
|
||||
auto cmp = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.day() <=> rhs.day();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare month_day with another.
|
||||
/// if month < other.month, returns -1;
|
||||
/// else if month > other.month, returns 1;
|
||||
/// else if day < other.day, returns -1;
|
||||
/// else if day > other.day, returns 1;
|
||||
/// else returns 0;
|
||||
/// if month < other.month, returns -1
|
||||
/// else if month > other.month, returns 1
|
||||
/// else if day < other.day, returns -1
|
||||
/// else if day > other.day, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const month_day& other) const ETL_NOEXCEPT
|
||||
@ -206,7 +117,215 @@ namespace etl
|
||||
|
||||
etl::chrono::month m;
|
||||
etl::chrono::day d;
|
||||
};
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.day() == rhs.day()) && (lhs.month() == rhs.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
if (lhs.month() < rhs.month())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lhs.month() == rhs.month())
|
||||
{
|
||||
return lhs.day() < rhs.day();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <=(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >=(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] inline constexpr auto operator <=>(const etl::chrono::month_day& lhs,
|
||||
const etl::chrono::month_day& rhs) noexcept
|
||||
{
|
||||
auto cmp = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.day() <=> rhs.day();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// month_day_last
|
||||
//*************************************************************************
|
||||
class month_day_last
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from month.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 explicit month_day_last(const etl::chrono::month& m_) ETL_NOEXCEPT
|
||||
: m(m_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get the month.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 etl::chrono::month month() const ETL_NOEXCEPT
|
||||
{
|
||||
return m;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Is the contained month OK?
|
||||
//*************************************************************************
|
||||
bool ok() const ETL_NOEXCEPT
|
||||
{
|
||||
return m.ok();
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare month_day with another.
|
||||
/// if month < other.month, returns -1
|
||||
/// else if month > other.month, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const month_day& other) const ETL_NOEXCEPT
|
||||
{
|
||||
if (m < other.month()) return -1;
|
||||
if (m > other.month()) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::chrono::month m;
|
||||
};
|
||||
|
||||
//***********************************************************************
|
||||
/// Equality operator
|
||||
//***********************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_day_last& mdl1,
|
||||
const etl::chrono::month_day_last& mdl2) ETL_NOEXCEPT
|
||||
{
|
||||
return (static_cast<unsigned>(mdl1.month()) == static_cast<unsigned>(mdl2.month()));
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Inequality operator
|
||||
//***********************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_day_last& mdl1,
|
||||
const etl::chrono::month_day_last& mdl2) ETL_NOEXCEPT
|
||||
{
|
||||
return !(mdl1 == mdl2);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <(const etl::chrono::month_day_last& lhs,
|
||||
const etl::chrono::month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.month() < rhs.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <=(const etl::chrono::month_day_last& lhs,
|
||||
const etl::chrono::month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >(const etl::chrono::month_day_last& lhs,
|
||||
const etl::chrono::month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >=(const etl::chrono::month_day_last& lhs,
|
||||
const etl::chrono::month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] inline constexpr auto operator <=>(const etl::chrono::month_day_last& mdl1, const etl::chrono::month_day_last& mdl2) noexcept
|
||||
{
|
||||
return (static_cast<unsigned>(mdl1.month()) <=> static_cast<unsigned>(mdl2.month()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -230,5 +349,22 @@ namespace etl
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function for etl::chrono::month_day_last
|
||||
//*************************************************************************
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
template <>
|
||||
struct hash<etl::chrono::month_day_last>
|
||||
{
|
||||
size_t operator()(const etl::chrono::month_day_last& mdl) const
|
||||
{
|
||||
etl::chrono::month::rep value = static_cast<etl::chrono::month::rep>(static_cast<unsigned>(mdl.month()));
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(&value);
|
||||
|
||||
return etl::private_hash::generic_hash<size_t>(p, p + sizeof(value));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -77,30 +77,31 @@ namespace etl
|
||||
return m.ok() && wdi.ok();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_weekday& lhs,
|
||||
const etl::chrono::month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.m == rhs.m) && (lhs.wdi == rhs.wdi);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_weekday& lhs,
|
||||
const etl::chrono::month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::chrono::month m;
|
||||
etl::chrono::weekday_indexed wdi;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_weekday& lhs,
|
||||
const etl::chrono::month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.month() == rhs.month()) &&
|
||||
(lhs.weekday_indexed() == rhs.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_weekday& lhs,
|
||||
const etl::chrono::month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from month and weekday_last.
|
||||
//*************************************************************************
|
||||
@ -145,29 +146,29 @@ namespace etl
|
||||
return m.ok() && wdl.ok();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_weekday_last& lhs,
|
||||
const etl::chrono::month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.m == rhs.m) && (lhs.wdl == rhs.wdl);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_weekday_last& lhs,
|
||||
const etl::chrono::month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::chrono::month m;
|
||||
etl::chrono::weekday_last wdl;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::month_weekday_last& lhs,
|
||||
const etl::chrono::month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.month() == rhs.month()) && (lhs.weekday_last() == rhs.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::month_weekday_last& lhs,
|
||||
const etl::chrono::month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -78,7 +78,7 @@ namespace etl
|
||||
/// Copy construct from another time_point with a different duration type.
|
||||
//***************************************************************************
|
||||
template <typename TDuration2>
|
||||
explicit time_point(const time_point<clock, TDuration2>& rhs) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 explicit time_point(const time_point<clock, TDuration2>& rhs) ETL_NOEXCEPT
|
||||
: dur(rhs.time_since_epoch())
|
||||
{
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Assignment operator.
|
||||
//***************************************************************************
|
||||
time_point& operator =(const time_point& rhs) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 time_point& operator =(const time_point& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
dur = rhs.dur;
|
||||
|
||||
@ -105,7 +105,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Adds a duration.
|
||||
//***************************************************************************
|
||||
time_point& operator +=(const duration& rhs) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 time_point& operator +=(const duration& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
dur += rhs;
|
||||
|
||||
@ -115,7 +115,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Subtracts a duration.
|
||||
//***************************************************************************
|
||||
time_point& operator -=(const duration& rhs) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 time_point& operator -=(const duration& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
dur -= rhs;
|
||||
|
||||
@ -140,6 +140,21 @@ namespace etl
|
||||
return time_point(duration::max());
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare day with another.
|
||||
/// if time_point < other, returns -1
|
||||
/// else if time_point > other, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const time_point& other) const ETL_NOEXCEPT
|
||||
{
|
||||
if (dur < other.dur) return -1;
|
||||
if (dur > other.dur) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
duration dur;
|
||||
|
||||
@ -187,6 +187,21 @@ namespace etl
|
||||
return static_cast<int>(value);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare year with another.
|
||||
/// if year < other, returns -1
|
||||
/// else if year > other, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const year& other) const ETL_NOEXCEPT
|
||||
{
|
||||
if (value < other.value) return -1;
|
||||
if (value > other.value) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
rep value;
|
||||
@ -334,9 +349,9 @@ namespace etl
|
||||
#if ETL_HAS_CHRONO_LITERALS_YEAR
|
||||
namespace etl
|
||||
{
|
||||
namespace literals
|
||||
inline namespace literals
|
||||
{
|
||||
namespace chrono_literals
|
||||
inline namespace chrono_literals
|
||||
{
|
||||
//***********************************************************************
|
||||
/// Literal for years
|
||||
|
||||
@ -86,115 +86,15 @@ namespace etl
|
||||
return y.ok() && m.ok();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year() + dy, ym.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month& ym) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year() + dy, ym.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year(), ym.month() + dm);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month& ym) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year(), ym.month() + dm);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month operator -(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year() - dy, ym.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month operator -(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year(), ym.month() - dm);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::year_month
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::months operator -(const etl::chrono::year_month& ym1,
|
||||
const etl::chrono::year_month& ym2) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::months(static_cast<int>(((int(ym1.year()) - int(ym2.year())) * 12) + (unsigned(ym1.month()) - unsigned(ym2.month()))));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.y == rhs.y) && (lhs.m == rhs.m);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp = lhs.year()<=> rhs.year();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.month() <=> rhs.month();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare year_month with another.
|
||||
/// if month < other.month, returns -1;
|
||||
/// else if month > other.month, returns 1;
|
||||
/// else if day < other.day, returns -1;
|
||||
/// else if day > other.day, returns 1;
|
||||
/// else returns 0;
|
||||
/// if month < other.month, returns -1
|
||||
/// else if month > other.month, returns 1
|
||||
/// else if day < other.day, returns -1
|
||||
/// else if day > other.day, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const year_month& other) const ETL_NOEXCEPT
|
||||
{
|
||||
if (y < other.y) return -1;
|
||||
@ -209,7 +109,159 @@ namespace etl
|
||||
|
||||
etl::chrono::year y;
|
||||
etl::chrono::month m;
|
||||
};
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year() + dy, ym.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month& ym) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year() + dy, ym.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year(), ym.month() + dm);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month& ym) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year(), ym.month() + dm);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month operator -(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year() - dy, ym.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month operator -(const etl::chrono::year_month& ym,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month(ym.year(), ym.month() - dm);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::year_month
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::months operator -(const etl::chrono::year_month& ym1,
|
||||
const etl::chrono::year_month& ym2) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::months(static_cast<int>(((int(ym1.year()) - int(ym2.year())) * 12) + (unsigned(ym1.month()) - unsigned(ym2.month()))));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.year() == rhs.year()) && (lhs.month() == rhs.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
if (lhs.year() < rhs.year())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lhs.year() == rhs.year())
|
||||
{
|
||||
return lhs.month() < rhs.month();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <=(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >=(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] inline constexpr auto operator <=>(const etl::chrono::year_month& lhs,
|
||||
const etl::chrono::year_month& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp = lhs.year()<=> rhs.year();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.month() <=> rhs.month();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -123,7 +123,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from sys_days.
|
||||
/// Construct from local_days.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 year_month_day(const etl::chrono::local_days& ld) ETL_NOEXCEPT
|
||||
{
|
||||
@ -175,111 +175,54 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
///
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 etl::chrono::year_month_day& operator +=(const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year() + dy, ymd.month(), ymd.day());
|
||||
y += dy;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
///
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_day& ymd) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 etl::chrono::year_month_day& operator +=(const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year() + dy, ymd.month(), ymd.day());
|
||||
m += dm;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
///
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 etl::chrono::year_month_day& operator -=(const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year(), ymd.month() + dm, ymd.day());
|
||||
y -= dy;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
///
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_day& ymd) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 etl::chrono::year_month_day& operator -=(const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year(), ymd.month() + dm, ymd.day());
|
||||
m -= dm;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day operator -(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year() - dy, ymd.month(), ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day operator -(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year(), ymd.month() - dm, ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.y == rhs.y) && (lhs.m == rhs.m) && (lhs.d == rhs.d);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp = lhs.year() <=> rhs.year();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return lhs.day() <=> rhs.day();
|
||||
}
|
||||
#endif
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare year_month_day with another.
|
||||
/// if year < other.year, returns -1;
|
||||
/// else if year > other.year, returns 1;
|
||||
/// if month < other.month, returns -1;
|
||||
/// else if month > other.month, returns 1;
|
||||
/// else if day < other.day, returns -1;
|
||||
/// else if day > other.day, returns 1;
|
||||
/// else returns 0;
|
||||
/// if year < other.year, returns -1
|
||||
/// else if year > other.year, returns 1
|
||||
/// if month < other.month, returns -1
|
||||
/// else if month > other.month, returns 1
|
||||
/// else if day < other.day, returns -1
|
||||
/// else if day > other.day, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const year_month_day& other) const ETL_NOEXCEPT
|
||||
@ -362,6 +305,163 @@ namespace etl
|
||||
etl::chrono::day d;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year() + dy, ymd.month(), ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_day& ymd) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year() + dy, ymd.month(), ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year(), ymd.month() + dm, ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_day& ymd) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year(), ymd.month() + dm, ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day operator -(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year() - dy, ymd.month(), ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day operator -(const etl::chrono::year_month_day& ymd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day(ymd.year(), ymd.month() - dm, ymd.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.year() == rhs.year()) &&
|
||||
(lhs.month() == rhs.month()) &&
|
||||
(lhs.day() == rhs.day());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
if (lhs.year() < rhs.year())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lhs.year() == rhs.year())
|
||||
{
|
||||
if (lhs.month() < rhs.month())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lhs.month() == rhs.month())
|
||||
{
|
||||
return (lhs.day() < rhs.day());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <=(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >=(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] inline constexpr auto operator <=>(const etl::chrono::year_month_day& lhs,
|
||||
const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp = lhs.year() <=> rhs.year();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
|
||||
cmp = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp != 0)
|
||||
{
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return lhs.day() <=> rhs.day();
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// year_month_day_last
|
||||
//*************************************************************************
|
||||
@ -466,114 +566,13 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year() + dy, ymdl.month_day_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_day_last& ymdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year() + dy, ymdl.month_day_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year(), etl::chrono::month_day_last(ymdl.month() + dm));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_day_last& ymdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year(), etl::chrono::month_day_last(ymdl.month() + dm));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator -(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year() - dy, ymdl.month_day_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator -(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year(), etl::chrono::month_day_last(ymdl.month() - dm));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.y == rhs.y) && (lhs.m == rhs.m);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp1 = lhs.year() <=> rhs.year();
|
||||
|
||||
if (cmp1 != 0)
|
||||
{
|
||||
return cmp1;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cmp2 = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp2 != 0)
|
||||
{
|
||||
return cmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.month() <=> rhs.month();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare year_month_day with another.
|
||||
/// if year < other.year, returns -1;
|
||||
/// else if year > other.year, returns 1;
|
||||
/// if month < other.month, returns -1;
|
||||
/// else if month > other.month, returns 1;
|
||||
/// else returns 0;
|
||||
/// if year < other.year, returns -1
|
||||
/// else if year > other.year, returns 1
|
||||
/// if month < other.month, returns -1
|
||||
/// else if month > other.month, returns 1
|
||||
/// else returns 0
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const year_month_day_last& other) const ETL_NOEXCEPT
|
||||
@ -612,6 +611,60 @@ namespace etl
|
||||
etl::chrono::month m;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year() + dy, ymdl.month_day_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_day_last& ymdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year() + dy, ymdl.month_day_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year(), etl::chrono::month_day_last(ymdl.month() + dm));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_day_last& ymdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year(), etl::chrono::month_day_last(ymdl.month() + dm));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator -(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year() - dy, ymdl.month_day_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_day_last operator -(const etl::chrono::year_month_day_last& ymdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_day_last(ymdl.year(), etl::chrono::month_day_last(ymdl.month() - dm));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from year_month_day_last.
|
||||
//*************************************************************************
|
||||
@ -621,6 +674,105 @@ namespace etl
|
||||
, d(ymdl.day())
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.year() == rhs.year()) &&
|
||||
(lhs.month() == rhs.month());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
if (lhs.year() < rhs.year())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lhs.year() == rhs.year())
|
||||
{
|
||||
return (lhs.month() < rhs.month());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Less-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator <=(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal operator.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
inline bool operator >=(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] inline constexpr auto operator <=>(const etl::chrono::year_month_day_last& lhs,
|
||||
const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp1 = lhs.year() <=> rhs.year();
|
||||
|
||||
if (cmp1 != 0)
|
||||
{
|
||||
return cmp1;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cmp2 = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp2 != 0)
|
||||
{
|
||||
return cmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.month() <=> rhs.month();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -160,78 +160,6 @@ namespace etl
|
||||
return y.ok() && m.ok() && wdi.ok();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year() + dy, ymwd.month(), ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_weekday& ymwd) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year() + dy, ymwd.month(), ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year(), ymwd.month() + dm, ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_weekday& ymwd) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year(), ymwd.month() + dm, ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator -(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year() - dy, ymwd.month(), ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator -(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year(), ymwd.month() - dm, ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_weekday& lhs,
|
||||
const etl::chrono::year_month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.y == rhs.y) && (lhs.m == rhs.m) && (lhs.wdi == rhs.wdi);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_weekday& lhs,
|
||||
const etl::chrono::year_month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Converts to etl::chrono::sys_days
|
||||
//***********************************************************************
|
||||
@ -280,6 +208,80 @@ namespace etl
|
||||
etl::chrono::weekday_indexed wdi;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year() + dy, ymwd.month(), ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_weekday& ymwd) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year() + dy, ymwd.month(), ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year(), ymwd.month() + dm, ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_weekday& ymwd) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year(), ymwd.month() + dm, ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator -(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year() - dy, ymwd.month(), ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday operator -(const etl::chrono::year_month_weekday& ymwd,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday(ymwd.year(), ymwd.month() - dm, ymwd.weekday_indexed());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_weekday& lhs,
|
||||
const etl::chrono::year_month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.year() == rhs.year()) &&
|
||||
(lhs.month() == rhs.month()) &&
|
||||
(lhs.weekday() == rhs.weekday());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_weekday& lhs,
|
||||
const etl::chrono::year_month_weekday& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// year_month_weekday_last
|
||||
//*************************************************************************
|
||||
@ -375,126 +377,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years and const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year() + dy, ymwdl.month(), ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years and const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_weekday_last& ymwdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year() + dy, ymwdl.month(), ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds const etl::chrono::year_month_weekday_last and etl::chrono::months.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year(), ymwdl.month() + dm, ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months and const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_weekday_last& ymwdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year(), ymwdl.month() + dm, ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years from const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator -(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year() - dy, ymwdl.month(), ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months from const etl::chrono::year_month_weekday_last
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator -(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year(), ymwdl.month() - dm, ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_weekday_last& lhs,
|
||||
const etl::chrono::year_month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.y == rhs.y) && (lhs.m == rhs.m) && (lhs.weekday() == rhs.weekday());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
friend ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_weekday_last& lhs,
|
||||
const etl::chrono::year_month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
/// Spaceship operator
|
||||
//***********************************************************************
|
||||
#if ETL_USING_CPP20
|
||||
[[nodiscard]] friend constexpr auto operator <=>(const etl::chrono::year_month_weekday_last& lhs,
|
||||
const etl::chrono::year_month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
auto cmp1 = lhs.year() <=> rhs.year();
|
||||
|
||||
if (cmp1 != 0)
|
||||
{
|
||||
return cmp1;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto cmp2 = lhs.month() <=> rhs.month();
|
||||
|
||||
if (cmp2 != 0)
|
||||
{
|
||||
return cmp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lhs.weekday().c_encoding() <=> rhs.weekday().c_encoding();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//***********************************************************************
|
||||
/// Compare year_month_weekday with another.
|
||||
/// if year < other.year, returns -1;
|
||||
/// else if year > other.year, returns 1;
|
||||
/// if month < other.month, returns -1;
|
||||
/// else if month > other.month, returns 1;
|
||||
/// else returns 0;
|
||||
//***********************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14 int compare(const etl::chrono::year_month_weekday_last& other) const ETL_NOEXCEPT
|
||||
{
|
||||
if (y < other.y) return -1;
|
||||
if (y > other.y) return 1;
|
||||
if (m < other.m) return -1;
|
||||
if (m > other.m) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Converts to etl::chrono::sys_days
|
||||
//*************************************************************************
|
||||
@ -539,6 +421,80 @@ namespace etl
|
||||
etl::chrono::month m;
|
||||
etl::chrono::weekday_last wdl;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years and const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year() + dy, ymwdl.month(), ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::years and const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::years& dy,
|
||||
const etl::chrono::year_month_weekday_last& ymwdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year() + dy, ymwdl.month(), ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds const etl::chrono::year_month_weekday_last and etl::chrono::months.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year(), ymwdl.month() + dm, ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Adds etl::chrono::months and const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator +(const etl::chrono::months& dm,
|
||||
const etl::chrono::year_month_weekday_last& ymwdl) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year(), ymwdl.month() + dm, ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::years from const etl::chrono::year_month_weekday_last.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator -(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::years& dy) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year() - dy, ymwdl.month(), ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Subtracts etl::chrono::months from const etl::chrono::year_month_weekday_last
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 etl::chrono::year_month_weekday_last operator -(const etl::chrono::year_month_weekday_last& ymwdl,
|
||||
const etl::chrono::months& dm) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::chrono::year_month_weekday_last(ymwdl.year(), ymwdl.month() - dm, ymwdl.weekday_last());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator ==(const etl::chrono::year_month_weekday_last& lhs,
|
||||
const etl::chrono::year_month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return (lhs.year() == rhs.year()) &&
|
||||
(lhs.month() == rhs.month()) &&
|
||||
(lhs.weekday() == rhs.weekday());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality operator.
|
||||
//*************************************************************************
|
||||
inline ETL_CONSTEXPR14 bool operator !=(const etl::chrono::year_month_weekday_last& lhs,
|
||||
const etl::chrono::year_month_weekday_last& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user