Skip to content

Commit 6078da5

Browse files
authored
Merge branch 'develop' into dev/139_render_this
2 parents bc090c4 + 95a1816 commit 6078da5

File tree

2 files changed

+186
-42
lines changed

2 files changed

+186
-42
lines changed

include/llfio/revision.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
22
#define LLFIO_PREVIOUS_COMMIT_REF e7b0ca825515759b49176417c4ae1aa0d5b8a890
3-
#define LLFIO_PREVIOUS_COMMIT_DATE "2024-08-27 11:12:38 +00:00"
3+
#define LLFIO_PREVIOUS_COMMIT_DATE "2024-08-23 11:19:37 +00:00"
44
#define LLFIO_PREVIOUS_COMMIT_UNIQUE e7b0ca82

include/llfio/v2.0/path_view.hpp

Lines changed: 185 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* A view of a path to something
2-
(C) 2017-2022 Niall Douglas <http://www.nedproductions.biz/> (20 commits)
2+
(C) 2017-2024 Niall Douglas <http://www.nedproductions.biz/> (20 commits)
33
File Created: Jul 2017
44
55
@@ -219,15 +219,20 @@ namespace detail
219219
class path_view;
220220
class path_view_component;
221221
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator==(path_view_component x, path_view_component y) noexcept;
222+
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator==(path_view x, path_view y) noexcept;
223+
#if __cplusplus >= 202000L || _HAS_CXX20
224+
inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view_component x, path_view_component y) noexcept;
225+
inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view x, path_view y) noexcept;
226+
#else
222227
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator!=(path_view_component x, path_view_component y) noexcept;
223228
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator<(path_view_component x, path_view_component y) noexcept;
229+
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator!=(path_view x, path_view y) noexcept;
230+
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator<(path_view x, path_view y) noexcept;
231+
#endif
224232
inline LLFIO_PATH_VIEW_CONSTEXPR size_t hash_value(path_view_component x) noexcept;
225233
template <class F> inline LLFIO_PATH_VIEW_CONSTEXPR auto visit(path_view_component view, F &&f);
226234
template <class F> inline LLFIO_PATH_VIEW_CONSTEXPR auto visit(F &&f, path_view_component view);
227235
inline std::ostream &operator<<(std::ostream &s, const path_view_component &v);
228-
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator==(path_view x, path_view y) noexcept;
229-
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator!=(path_view x, path_view y) noexcept;
230-
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator<(path_view x, path_view y) noexcept;
231236
inline LLFIO_PATH_VIEW_CONSTEXPR size_t hash_value(path_view x) noexcept;
232237

233238
/*! \class path_view_component
@@ -238,21 +243,11 @@ class LLFIO_DECL path_view_component
238243
friend class path_view;
239244
friend class detail::path_view_iterator;
240245
friend inline LLFIO_PATH_VIEW_CONSTEXPR bool LLFIO_V2_NAMESPACE::operator==(path_view_component x, path_view_component y) noexcept;
246+
#if __cplusplus >= 202000L || _HAS_CXX20
247+
friend inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view_component x, path_view_component y) noexcept;
248+
#else
241249
friend inline LLFIO_PATH_VIEW_CONSTEXPR bool LLFIO_V2_NAMESPACE::operator!=(path_view_component x, path_view_component y) noexcept;
242250
friend inline LLFIO_PATH_VIEW_CONSTEXPR bool LLFIO_V2_NAMESPACE::operator<(path_view_component x, path_view_component y) noexcept;
243-
#if __cplusplus >= 202000L || _HAS_CXX20
244-
friend inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view_component x, path_view_component y) noexcept
245-
{
246-
if(x == y)
247-
{
248-
return std::strong_ordering::equal;
249-
}
250-
if(x < y)
251-
{
252-
return std::strong_ordering::less;
253-
}
254-
return std::strong_ordering::greater;
255-
}
256251
#endif
257252
friend inline LLFIO_PATH_VIEW_CONSTEXPR size_t hash_value(path_view_component x) noexcept;
258253
template <class F> friend inline LLFIO_PATH_VIEW_CONSTEXPR auto LLFIO_V2_NAMESPACE::visit(path_view_component view, F &&f);
@@ -1596,6 +1591,7 @@ class LLFIO_DECL path_view_component
15961591
};
15971592
static_assert(std::is_trivially_copyable<path_view_component>::value, "path_view_component is not trivially copyable!");
15981593
static_assert(sizeof(path_view_component) == 3 * sizeof(void *), "path_view_component is not three pointers in size!");
1594+
15991595
//! \brief Compares **identity** equality not equivalence i.e. backing storage type must be identical, and backing bytes must be identical. Use `compare()` if
16001596
//! you want something stronger.
16011597
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator==(path_view_component x, path_view_component y) noexcept
@@ -1633,6 +1629,106 @@ inline LLFIO_PATH_VIEW_CONSTEXPR bool operator==(path_view_component x, path_vie
16331629
const auto bytes = (x._wchar || x._utf16) ? (x._length * 2) : x._length;
16341630
return 0 == memcmp(x._bytestr, y._bytestr, bytes);
16351631
}
1632+
LLFIO_TEMPLATE(class CharT)
1633+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1634+
inline constexpr bool operator==(path_view_component /*unused*/, const CharT * /*unused*/) noexcept
1635+
{
1636+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator== with path_view_component and a string literal, use .compare<>()");
1637+
return false;
1638+
}
1639+
LLFIO_TEMPLATE(class CharT)
1640+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1641+
inline constexpr bool operator==(const CharT * /*unused*/, path_view_component /*unused*/) noexcept
1642+
{
1643+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator== with path_view_component and a string literal, use .compare<>()");
1644+
return false;
1645+
}
1646+
#if __cplusplus >= 202000L || _HAS_CXX20
1647+
inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view_component x, path_view_component y) noexcept
1648+
{
1649+
if(x.native_size() < y.native_size())
1650+
{
1651+
return std::strong_ordering::less;
1652+
}
1653+
if(x.native_size() > y.native_size())
1654+
{
1655+
return std::strong_ordering::greater;
1656+
}
1657+
if(x._passthrough < y._passthrough)
1658+
{
1659+
return std::strong_ordering::less;
1660+
}
1661+
if(x._passthrough > y._passthrough)
1662+
{
1663+
return std::strong_ordering::greater;
1664+
}
1665+
if(x._char < y._char)
1666+
{
1667+
return std::strong_ordering::less;
1668+
}
1669+
if(x._char > y._char)
1670+
{
1671+
return std::strong_ordering::greater;
1672+
}
1673+
if(x._wchar < y._wchar)
1674+
{
1675+
return std::strong_ordering::less;
1676+
}
1677+
if(x._wchar > y._wchar)
1678+
{
1679+
return std::strong_ordering::greater;
1680+
}
1681+
if(x._utf8 < y._utf8)
1682+
{
1683+
return std::strong_ordering::less;
1684+
}
1685+
if(x._utf8 > y._utf8)
1686+
{
1687+
return std::strong_ordering::greater;
1688+
}
1689+
if(x._utf16 < y._utf16)
1690+
{
1691+
return std::strong_ordering::less;
1692+
}
1693+
if(x._utf16 > y._utf16)
1694+
{
1695+
return std::strong_ordering::greater;
1696+
}
1697+
if(x.native_size() == 0)
1698+
{
1699+
return std::strong_ordering::equal;
1700+
}
1701+
assert(x._bytestr != nullptr);
1702+
assert(y._bytestr != nullptr);
1703+
const auto bytes = (x._wchar || x._utf16) ? (x._length * 2) : x._length;
1704+
int comp = memcmp(x._bytestr, y._bytestr, bytes);
1705+
if(comp == 0)
1706+
{
1707+
return std::strong_ordering::equal;
1708+
}
1709+
else if(comp < 0)
1710+
{
1711+
return std::strong_ordering::less;
1712+
}
1713+
return std::strong_ordering::greater;
1714+
}
1715+
1716+
LLFIO_TEMPLATE(class CharT)
1717+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1718+
inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view_component /*unused*/, const CharT * /*unused*/) noexcept
1719+
{
1720+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator<=> with path_view_component and a string literal, use .compare<>()");
1721+
return std::strong_ordering::equal;
1722+
}
1723+
LLFIO_TEMPLATE(class CharT)
1724+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1725+
inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(const CharT * /*unused*/, path_view_component /*unused*/) noexcept
1726+
{
1727+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator<=> with path_view_component and a string literal, use .compare<>()");
1728+
return std::strong_ordering::equal;
1729+
}
1730+
1731+
#else
16361732
//! \brief Compares **identity** inequality not disequivalence i.e. backing storage type must be different, or backing bytes must be different. Use `compare()`
16371733
//! if you want something stronger.
16381734
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator!=(path_view_component x, path_view_component y) noexcept
@@ -1734,32 +1830,34 @@ inline LLFIO_PATH_VIEW_CONSTEXPR bool operator<(path_view_component x, path_view
17341830

17351831
LLFIO_TEMPLATE(class CharT)
17361832
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1737-
inline constexpr bool operator==(path_view_component /*unused*/, const CharT * /*unused*/) noexcept
1833+
inline constexpr bool operator!=(path_view_component /*unused*/, const CharT * /*unused*/) noexcept
17381834
{
1739-
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator== with path_view_component and a string literal, use .compare<>()");
1835+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator!= with path_view_component and a string literal, use .compare<>()");
17401836
return false;
17411837
}
17421838
LLFIO_TEMPLATE(class CharT)
17431839
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1744-
inline constexpr bool operator==(const CharT * /*unused*/, path_view_component /*unused*/) noexcept
1840+
inline constexpr bool operator!=(const CharT * /*unused*/, path_view_component /*unused*/) noexcept
17451841
{
1746-
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator== with path_view_component and a string literal, use .compare<>()");
1842+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator!= with path_view_component and a string literal, use .compare<>()");
17471843
return false;
17481844
}
17491845
LLFIO_TEMPLATE(class CharT)
17501846
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1751-
inline constexpr bool operator!=(path_view_component /*unused*/, const CharT * /*unused*/) noexcept
1847+
inline constexpr bool operator<(path_view_component /*unused*/, const CharT * /*unused*/) noexcept
17521848
{
1753-
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator!= with path_view_component and a string literal, use .compare<>()");
1849+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator< with path_view_component and a string literal, use .compare<>()");
17541850
return false;
17551851
}
17561852
LLFIO_TEMPLATE(class CharT)
17571853
LLFIO_TREQUIRES(LLFIO_TPRED(path_view_component::is_source_acceptable<CharT>))
1758-
inline constexpr bool operator!=(const CharT * /*unused*/, path_view_component /*unused*/) noexcept
1854+
inline constexpr bool operator<(const CharT * /*unused*/, path_view_component /*unused*/) noexcept
17591855
{
1760-
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator!= with path_view_component and a string literal, use .compare<>()");
1856+
static_assert(!path_view_component::is_source_acceptable<CharT>, "Do not use operator< with path_view_component and a string literal, use .compare<>()");
17611857
return false;
17621858
}
1859+
#endif
1860+
17631861
//! \brief Hashes a `path_view_component`.
17641862
inline LLFIO_PATH_VIEW_CONSTEXPR size_t hash_value(path_view_component view) noexcept
17651863
{
@@ -1913,10 +2011,11 @@ class path_view : public path_view_component
19132011
{
19142012
friend class detail::path_view_iterator;
19152013
friend inline LLFIO_PATH_VIEW_CONSTEXPR bool LLFIO_V2_NAMESPACE::operator==(path_view x, path_view y) noexcept;
2014+
#if __cplusplus >= 202000L || _HAS_CXX20
2015+
friend inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view x, path_view y) noexcept;
2016+
#else
19162017
friend inline LLFIO_PATH_VIEW_CONSTEXPR bool LLFIO_V2_NAMESPACE::operator!=(path_view x, path_view y) noexcept;
19172018
friend inline LLFIO_PATH_VIEW_CONSTEXPR bool LLFIO_V2_NAMESPACE::operator<(path_view x, path_view y) noexcept;
1918-
#if __cplusplus >= 202000L || _HAS_CXX20
1919-
friend inline LLFIO_PATH_VIEW_CONSTEXPR auto operator<=>(path_view x, path_view y) = default;
19202019
#endif
19212020
friend inline LLFIO_PATH_VIEW_CONSTEXPR size_t hash_value(path_view x) noexcept;
19222021

@@ -2859,6 +2958,60 @@ inline LLFIO_PATH_VIEW_CONSTEXPR bool operator==(path_view x, path_view y) noexc
28592958
}
28602959
return true;
28612960
}
2961+
LLFIO_TEMPLATE(class CharT)
2962+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
2963+
inline constexpr bool operator==(path_view /*unused*/, const CharT * /*unused*/) noexcept
2964+
{
2965+
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator== with path_view and a string literal, use .compare<>()");
2966+
return false;
2967+
}
2968+
LLFIO_TEMPLATE(class CharT)
2969+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
2970+
inline constexpr bool operator==(const CharT * /*unused*/, path_view /*unused*/) noexcept
2971+
{
2972+
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator== with path_view and a string literal, use .compare<>()");
2973+
return false;
2974+
}
2975+
#if __cplusplus >= 202000L || _HAS_CXX20
2976+
inline LLFIO_PATH_VIEW_CONSTEXPR std::strong_ordering operator<=>(path_view x, path_view y) noexcept
2977+
{
2978+
auto it1 = x.begin(), it2 = y.begin();
2979+
for(; it1 != x.end() && it2 != y.end(); ++it1, ++it2)
2980+
{
2981+
if(*it1 < *it2)
2982+
{
2983+
return std::strong_ordering::less;
2984+
}
2985+
if(*it1 > *it2)
2986+
{
2987+
return std::strong_ordering::greater;
2988+
}
2989+
}
2990+
if(it1 == x.end() && it2 != y.end())
2991+
{
2992+
return std::strong_ordering::less;
2993+
}
2994+
if(it2 == x.end() && it1 != y.end())
2995+
{
2996+
return std::strong_ordering::greater;
2997+
}
2998+
return std::strong_ordering::equal;
2999+
}
3000+
LLFIO_TEMPLATE(class CharT)
3001+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
3002+
inline constexpr std::strong_ordering operator<=>(path_view /*unused*/, const CharT * /*unused*/) noexcept
3003+
{
3004+
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator<=> with path_view and a string literal, use .compare<>()");
3005+
return std::strong_ordering::equal;
3006+
}
3007+
LLFIO_TEMPLATE(class CharT)
3008+
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
3009+
inline constexpr std::strong_ordering operator<=>(const CharT * /*unused*/, path_view /*unused*/) noexcept
3010+
{
3011+
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator<=> with path_view and a string literal, use .compare<>()");
3012+
return std::strong_ordering::equal;
3013+
}
3014+
#else
28623015
//! \brief Compares individual path view components for non-**identity** not disequivalence. Use `compare()` if you want something stronger.
28633016
inline LLFIO_PATH_VIEW_CONSTEXPR bool operator!=(path_view x, path_view y) noexcept
28643017
{
@@ -2890,6 +3043,10 @@ inline LLFIO_PATH_VIEW_CONSTEXPR bool operator<(path_view x, path_view y) noexce
28903043
{
28913044
return true;
28923045
}
3046+
if(*it2 < *it1)
3047+
{
3048+
return false;
3049+
}
28933050
}
28943051
if(it1 == x.end() && it2 != y.end())
28953052
{
@@ -2899,20 +3056,6 @@ inline LLFIO_PATH_VIEW_CONSTEXPR bool operator<(path_view x, path_view y) noexce
28993056
}
29003057
LLFIO_TEMPLATE(class CharT)
29013058
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
2902-
inline constexpr bool operator==(path_view /*unused*/, const CharT * /*unused*/) noexcept
2903-
{
2904-
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator== with path_view and a string literal, use .compare<>()");
2905-
return false;
2906-
}
2907-
LLFIO_TEMPLATE(class CharT)
2908-
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
2909-
inline constexpr bool operator==(const CharT * /*unused*/, path_view /*unused*/) noexcept
2910-
{
2911-
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator== with path_view and a string literal, use .compare<>()");
2912-
return false;
2913-
}
2914-
LLFIO_TEMPLATE(class CharT)
2915-
LLFIO_TREQUIRES(LLFIO_TPRED(path_view::is_source_acceptable<CharT>))
29163059
inline constexpr bool operator!=(path_view /*unused*/, const CharT * /*unused*/) noexcept
29173060
{
29183061
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator!= with path_view and a string literal, use .compare<>()");
@@ -2925,6 +3068,7 @@ inline constexpr bool operator!=(const CharT * /*unused*/, path_view /*unused*/)
29253068
static_assert(!path_view::is_source_acceptable<CharT>, "Do not use operator!= with path_view and a string literal, use .compare<>()");
29263069
return false;
29273070
}
3071+
#endif
29283072
//! \brief Return the combined hash of individual path components
29293073
inline LLFIO_PATH_VIEW_CONSTEXPR size_t hash_value(path_view x) noexcept
29303074
{

0 commit comments

Comments
 (0)