Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libcxx/docs/ReleaseNotes/22.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ What's New in Libc++ 22.0.0?
Implemented Papers
------------------

- P2592R3: Hashing support for ``std::chrono`` value classes (`Github <https://llvm.org/PR105358>`__)
- P2321R2: ``zip`` (`Github <https://llvm.org/PR105169>`__) (The paper is partially implemented. ``zip_transform_view``
is implemented in this release)
- P3044R2: sub-``string_view`` from ``string`` (`Github <https://llvm.org/PR148140>`__)
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx2cPapers.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Paper #","Paper Name","Meeting","Status","First released version","GitHub issue","Notes"
"`P2497R0 <https://wg21.link/P2497R0>`__","Testing for success or failure of ``<charconv>`` functions","2023-06 (Varna)","|Complete|","18","`#105357 <https://github.com/llvm/llvm-project/issues/105357>`__",""
"`P2592R3 <https://wg21.link/P2592R3>`__","Hashing support for ``std::chrono`` value classes","2023-06 (Varna)","","","`#105358 <https://github.com/llvm/llvm-project/issues/105358>`__",""
"`P2592R3 <https://wg21.link/P2592R3>`__","Hashing support for ``std::chrono`` value classes","2023-06 (Varna)","|Complete|","22","`#105358 <https://github.com/llvm/llvm-project/issues/105358>`__",""
"`P2587R3 <https://wg21.link/P2587R3>`__","``to_string`` or not ``to_string``","2023-06 (Varna)","","","`#105359 <https://github.com/llvm/llvm-project/issues/105359>`__",""
"`P2562R1 <https://wg21.link/P2562R1>`__","``constexpr`` Stable Sorting","2023-06 (Varna)","|Complete|","21","`#105360 <https://github.com/llvm/llvm-project/issues/105360>`__",""
"`P2545R4 <https://wg21.link/P2545R4>`__","Read-Copy Update (RCU)","2023-06 (Varna)","","","`#105361 <https://github.com/llvm/llvm-project/issues/105361>`__",""
Expand Down
11 changes: 11 additions & 0 deletions libcxx/include/__chrono/day.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <__chrono/duration.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -92,6 +94,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) no

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::day> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::day& __d) noexcept { return static_cast<unsigned>(__d); }
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
14 changes: 14 additions & 0 deletions libcxx/include/__chrono/duration.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <__compare/ordering.h>
#include <__compare/three_way_comparable.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <__type_traits/common_type.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_convertible.h>
Expand Down Expand Up @@ -538,6 +540,18 @@ using namespace literals::chrono_literals;

#endif // _LIBCPP_STD_VER >= 14

#if _LIBCPP_STD_VER >= 26

template <class _Rep, class _Period>
requires __has_enabled_hash<_Rep>::value
struct hash<chrono::duration<_Rep, _Period>> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::duration<_Rep, _Period>& __d) {
return hash<_Rep>{}(__d.count());
}
};

#endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS
Expand Down
13 changes: 13 additions & 0 deletions libcxx/include/__chrono/leap_second.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# include <__compare/ordering.h>
# include <__compare/three_way_comparable.h>
# include <__config>
# include <__cstddef/size_t.h>
# include <__functional/hash.h>
# include <__utility/private_constructor_tag.h>

# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -122,6 +124,17 @@ class leap_second {

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::leap_second> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::leap_second& __lp) noexcept {
return std::__hash_combine(hash<chrono::sys_seconds>{}(__lp.date()), hash<chrono::seconds>{}(__lp.value()));
}
};

# endif // _LIBCPP_STD_VER >= 26

# endif // _LIBCPP_STD_VER >= 20

_LIBCPP_END_NAMESPACE_STD
Expand Down
13 changes: 13 additions & 0 deletions libcxx/include/__chrono/month.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <__chrono/duration.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -108,6 +110,17 @@ inline constexpr month December{12};

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::month> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month& __m) noexcept {
return static_cast<unsigned>(__m);
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
22 changes: 22 additions & 0 deletions libcxx/include/__chrono/month_weekday.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <__chrono/month.h>
#include <__chrono/weekday.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -98,6 +100,26 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekda
}
} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::month_weekday> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday& __mw) noexcept {
return std::__hash_combine(
hash<chrono::month>{}(__mw.month()), hash<chrono::weekday_indexed>{}(__mw.weekday_indexed()));
}
};

template <>
struct hash<chrono::month_weekday_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday_last& __mwl) noexcept {
return std::__hash_combine(
hash<chrono::month>{}(__mwl.month()), hash<chrono::weekday_last>{}(__mwl.weekday_last()));
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
20 changes: 20 additions & 0 deletions libcxx/include/__chrono/monthday.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <__chrono/month.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -126,6 +128,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int _

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::month_day> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day& __md) noexcept {
return std::__hash_combine(hash<chrono::month>{}(__md.month()), hash<chrono::day>{}(__md.day()));
}
};

template <>
struct hash<chrono::month_day_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day_last& __mdl) noexcept {
return hash<chrono::month>{}(__mdl.month());
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
14 changes: 14 additions & 0 deletions libcxx/include/__chrono/time_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <__compare/ordering.h>
#include <__compare/three_way_comparable.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <__type_traits/common_type.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_convertible.h>
Expand Down Expand Up @@ -224,6 +226,18 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,

} // namespace chrono

#if _LIBCPP_STD_VER >= 26

template <class _Clock, class _Duration>
requires __has_enabled_hash<_Duration>::value
struct hash<chrono::time_point<_Clock, _Duration>> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::time_point<_Clock, _Duration>& __tp) {
return hash<_Duration>{}(__tp.time_since_epoch());
}
};

#endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS
Expand Down
25 changes: 25 additions & 0 deletions libcxx/include/__chrono/weekday.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <__chrono/system_clock.h>
#include <__chrono/time_point.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -160,6 +162,29 @@ inline constexpr weekday Saturday{6};

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::weekday> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept { return __w.c_encoding(); }
};

template <>
struct hash<chrono::weekday_indexed> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_indexed& __wi) noexcept {
return std::__hash_combine(hash<chrono::weekday>{}(__wi.weekday()), __wi.index());
}
};

template <>
struct hash<chrono::weekday_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_last& __wl) noexcept {
return hash<chrono::weekday>{}(__wl.weekday());
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
11 changes: 11 additions & 0 deletions libcxx/include/__chrono/year.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <__chrono/duration.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <limits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -109,6 +111,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::year> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept { return static_cast<int>(__y); }
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
13 changes: 13 additions & 0 deletions libcxx/include/__chrono/year_month.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <__chrono/year.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -116,6 +118,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& year_month::operator-=(const

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::year_month> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month& __ym) noexcept {
return std::__hash_combine(hash<chrono::year>{}(__ym.year()), hash<chrono::month>{}(__ym.month()));
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
23 changes: 23 additions & 0 deletions libcxx/include/__chrono/year_month_day.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <__chrono/year_month.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <limits>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down Expand Up @@ -330,6 +332,27 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool year_month_day::ok() const noexcept

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::year_month_day> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day& __ymd) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymd.year()),
std::__hash_combine(hash<chrono::month>{}(__ymd.month()), hash<chrono::day>{}(__ymd.day())));
}
};

template <>
struct hash<chrono::year_month_day_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day_last& __ymdl) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymdl.year()), hash<chrono::month_day_last>{}(__ymdl.month_day_last()));
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
26 changes: 26 additions & 0 deletions libcxx/include/__chrono/year_month_weekday.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <__chrono/year_month.h>
#include <__chrono/year_month_day.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -280,6 +282,30 @@ year_month_weekday_last::operator-=(const years& __dy) noexcept {

} // namespace chrono

# if _LIBCPP_STD_VER >= 26

template <>
struct hash<chrono::year_month_weekday> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday& __ymw) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymw.year()),
std::__hash_combine(
hash<chrono::month>{}(__ymw.month()), hash<chrono::weekday_indexed>{}(__ymw.weekday_indexed())));
}
};

template <>
struct hash<chrono::year_month_weekday_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday_last& __ymwl) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymwl.year()),
std::__hash_combine(
hash<chrono::month>{}(__ymwl.month()), hash<chrono::weekday_last>{}(__ymwl.weekday_last())));
}
};

# endif // _LIBCPP_STD_VER >= 26

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP_STD_VER >= 20
Expand Down
Loading