33
44namespace kf
55{
6- using namespace std ;
7-
86 template <class T , class U >
9- inline constexpr span<T> span_cast (span<U> input) noexcept
7+ inline constexpr std:: span<T> span_cast (std:: span<U> input) noexcept
108 {
119 return { reinterpret_cast <T*>(input.data ()), input.size_bytes () / sizeof (T) };
1210 }
1311
1412 template <class T , class U >
15- inline constexpr span<T> span_cast (U* data, size_t size) noexcept
13+ inline constexpr std:: span<T> span_cast (U* data, size_t size) noexcept
1614 {
1715 return { reinterpret_cast <T*>(data), size * sizeof (U) / sizeof (T) };
1816 }
1917
20- inline constexpr span<const std::byte> as_bytes (const void * p, size_t size) noexcept
18+ inline constexpr std:: span<const std::byte> as_bytes (const void * p, size_t size) noexcept
2119 {
2220 return { static_cast <const std::byte*>(p), size };
2321 }
@@ -26,10 +24,10 @@ namespace kf
2624 template <class T , size_t N>
2725 inline constexpr auto as_bytes (const T (&p)[N]) noexcept
2826 {
29- return span<const std::byte, sizeof (T)* N>{ reinterpret_cast <const std::byte*>(p), sizeof (p) };
27+ return std:: span<const std::byte, sizeof (T)* N>{ reinterpret_cast <const std::byte*>(p), sizeof (p) };
3028 }
3129
32- inline constexpr span<std::byte> as_writable_bytes (void * p, size_t size) noexcept
30+ inline constexpr std:: span<std::byte> as_writable_bytes (void * p, size_t size) noexcept
3331 {
3432 return { static_cast <std::byte*>(p), size };
3533 }
@@ -38,11 +36,11 @@ namespace kf
3836 template <class T , size_t N>
3937 inline constexpr auto as_writable_bytes (T(&p)[N]) noexcept
4038 {
41- return span<std::byte, sizeof (T) * N>{ reinterpret_cast <std::byte*>(p), sizeof (p) };
39+ return std:: span<std::byte, sizeof (T) * N>{ reinterpret_cast <std::byte*>(p), sizeof (p) };
4240 }
4341
4442 template <class T , size_t dstExtent, size_t srcExtent>
45- inline constexpr span<T> copyTruncate (span<T, dstExtent> dst, span<const T, srcExtent> src) noexcept
43+ inline constexpr std:: span<T> copyTruncate (std:: span<T, dstExtent> dst, std:: span<const T, srcExtent> src) noexcept
4644 {
4745 //
4846 // Source can be larger than destination, truncate in such case
@@ -54,17 +52,17 @@ namespace kf
5452 }
5553
5654 template <class T , size_t dstExtent, size_t srcExtent>
57- inline constexpr span<T> copyExact (span<T, dstExtent> dst, span<const T, srcExtent> src) noexcept
55+ inline constexpr std:: span<T> copyExact (std:: span<T, dstExtent> dst, std:: span<const T, srcExtent> src) noexcept
5856 {
5957 //
6058 // Source MUST be equal to destination
6159 //
6260
63- if constexpr (dstExtent == dynamic_extent || srcExtent == dynamic_extent)
61+ if constexpr (dstExtent == std:: dynamic_extent || srcExtent == std:: dynamic_extent)
6462 {
6563 if (dst.size () != src.size ())
6664 {
67- _Xinvalid_argument (" dst.size() != src.size()" );
65+ std:: _Xinvalid_argument (" dst.size() != src.size()" );
6866 }
6967 }
7068 else
@@ -76,17 +74,17 @@ namespace kf
7674 }
7775
7876 template <class T , size_t dstExtent, size_t srcExtent>
79- inline constexpr span<T> copy (span<T, dstExtent> dst, span<const T, srcExtent> src) noexcept
77+ inline constexpr std:: span<T> copy (std:: span<T, dstExtent> dst, std:: span<const T, srcExtent> src) noexcept
8078 {
8179 //
8280 // Source MUST be smaller or equal to destination
8381 //
8482
85- if constexpr (dstExtent == dynamic_extent || srcExtent == dynamic_extent)
83+ if constexpr (dstExtent == std:: dynamic_extent || srcExtent == std:: dynamic_extent)
8684 {
8785 if (dst.size () < src.size ())
8886 {
89- _Xinvalid_argument (" dst.size() < src.size()" );
87+ std:: _Xinvalid_argument (" dst.size() < src.size()" );
9088 }
9189 }
9290 else
@@ -98,13 +96,13 @@ namespace kf
9896 }
9997
10098 template <class T , size_t LeftExtent, size_t RightExtent>
101- inline constexpr bool equals (span<T, LeftExtent> left, span<T, RightExtent> right) noexcept
99+ inline constexpr bool equals (std:: span<T, LeftExtent> left, std:: span<T, RightExtent> right) noexcept
102100 {
103101 return std::equal (left.begin (), left.end (), right.begin (), right.end ());
104102 }
105103
106104 template <class T >
107- inline constexpr ptrdiff_t indexOf (span<T> input, typename span<T>::const_reference elem, ptrdiff_t fromIndex = 0 ) noexcept
105+ inline constexpr ptrdiff_t indexOf (std:: span<T> input, typename std:: span<T>::const_reference elem, ptrdiff_t fromIndex = 0 ) noexcept
108106 {
109107 for (auto i = fromIndex; i < ssize (input); ++i)
110108 {
@@ -118,7 +116,7 @@ namespace kf
118116 }
119117
120118 template <class T >
121- inline constexpr span<T> split (span<T> input, typename span<T>::const_reference separator, _Inout_ ptrdiff_t & fromIndex) noexcept
119+ inline constexpr std:: span<T> split (std:: span<T> input, typename std:: span<T>::const_reference separator, _Inout_ ptrdiff_t & fromIndex) noexcept
122120 {
123121 auto originalFromIndex = fromIndex;
124122
@@ -135,7 +133,7 @@ namespace kf
135133 }
136134
137135 template <class T >
138- inline constexpr T atOrDefault (span<T> input, size_t index, convertible_to<T> auto defaultValue) noexcept
136+ inline constexpr T atOrDefault (std:: span<T> input, size_t index, std:: convertible_to<T> auto defaultValue) noexcept
139137 {
140138 return input.size () > index ? input[index] : defaultValue;
141139 }
0 commit comments