Skip to content

Commit 68549bc

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Headers: Add C++20 span header Headers: Add C++17 std::byte to cstddef Headers: Add C++17 std::basic_string::data() overload Headers: Put integer typedefs to global namespace too by default Bump lxml from 4.6.5 to 4.9.1
2 parents 9d7260a + 4702428 commit 68549bc

File tree

6 files changed

+197
-1
lines changed

6 files changed

+197
-1
lines changed

headers/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ macros:
3232
values are 1998, 2003, 2011, 2014, 2017 which correspond to the respective
3333
C++ standards.
3434

35+
- CPPREFERENCE_INT_TYPES_ONLY_IN_STD: non-zero value results in integer types
36+
such as std::size_t, std::uint16_t and so on being defined only in std
37+
namespace.
38+
3539
- CPPREFERENCE_SIMPLIFY_TYPEDEFS: non-zero value results in simplified
3640
typedefs being exposed. Usage of various traits is greatly reduced; the
3741
typedefs refer to types that would be resolved in most common cases.

headers/cstddef

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,41 @@ typedef void* nullptr_t;
3636
typedef decltype(nullptr) nullptr_t;
3737
#endif
3838
#endif
39+
40+
#if CPPREFERENCE_STDVER >= 2017
41+
enum class byte : unsigned char {};
42+
43+
template<class IntegerType>
44+
constexpr IntegerType to_integer(std::byte b) noexcept;
45+
46+
constexpr std::byte operator|(std::byte l, std::byte r) noexcept;
47+
constexpr std::byte operator&(std::byte l, std::byte r) noexcept;
48+
constexpr std::byte operator^(std::byte l, std::byte r) noexcept;
49+
constexpr std::byte operator~(std::byte b) noexcept;
50+
51+
constexpr std::byte& operator|=(std::byte& l, std::byte r) noexcept;
52+
constexpr std::byte& operator&=(std::byte& l, std::byte r) noexcept;
53+
constexpr std::byte& operator^=(std::byte& l, std::byte r) noexcept;
54+
55+
template <class IntegerType>
56+
constexpr std::byte operator<<(std::byte b, IntegerType shift) noexcept;
57+
58+
template <class IntegerType>
59+
constexpr std::byte operator>>(std::byte b, IntegerType shift) noexcept;
60+
61+
template <class IntegerType>
62+
constexpr std::byte& operator<<=(std::byte& b, IntegerType shift) noexcept;
63+
64+
template <class IntegerType>
65+
constexpr std::byte& operator>>=(std::byte& b, IntegerType shift) noexcept;
66+
#endif
67+
3968
} // namespace std
4069

70+
#if !CPPREFERENCE_INT_TYPES_ONLY_IN_STD
71+
using std::ptrdiff_t;
72+
using std::size_t;
73+
using std::max_align_t;
74+
#endif // !CPPREFERENCE_INT_TYPES_ONLY_IN_STD
75+
4176
#endif // CPPREFERENCE_CSTDDEF_H

headers/cstdint

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,36 @@ typedef unsigned long long uintmax_t;
142142
} // namespace std
143143
#endif // CPPREFERENCE_STDVER>= 2011
144144

145+
#if !CPPREFERENCE_INT_TYPES_ONLY_IN_STD
146+
using std::int8_t;
147+
using std::int16_t;
148+
using std::int32_t;
149+
using std::int64_t;
150+
using std::uint8_t;
151+
using std::uint16_t;
152+
using std::uint32_t;
153+
using std::uint64_t;
154+
using std::int_fast8_t;
155+
using std::int_fast16_t;
156+
using std::int_fast32_t;
157+
using std::int_fast64_t;
158+
using std::uint_fast8_t;
159+
using std::uint_fast16_t;
160+
using std::uint_fast32_t;
161+
using std::uint_fast64_t;
162+
using std::int_least8_t;
163+
using std::int_least16_t;
164+
using std::int_least32_t;
165+
using std::int_least64_t;
166+
using std::uint_least8_t;
167+
using std::uint_least16_t;
168+
using std::uint_least32_t;
169+
using std::uint_least64_t;
170+
171+
using std::intptr_t;
172+
using std::uintptr_t;
173+
using std::intmax_t;
174+
using std::uintmax_t;
175+
#endif
176+
145177
#endif // CPPREFERENCE_CSTDINT_H

headers/span

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/* Copyright (C) 2023 Povilas Kanapickas <povilas@radix.lt>
2+
3+
This file is part of cppreference-doc
4+
5+
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
6+
Unported License. To view a copy of this license, visit
7+
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
8+
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
9+
10+
Permission is granted to copy, distribute and/or modify this document
11+
under the terms of the GNU Free Documentation License, Version 1.3 or
12+
any later version published by the Free Software Foundation; with no
13+
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
14+
*/
15+
16+
#ifndef CPPREFERENCE_SPAN_H
17+
#define CPPREFERENCE_SPAN_H
18+
19+
#if CPPREFERENCE_STDVER >= 2020
20+
21+
#include <cstddef>
22+
#include <limits>
23+
#include <type_traits>
24+
25+
namespace std {
26+
27+
inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
28+
29+
template<class T, size_t Extent = dynamic_extent>
30+
class span {
31+
using element_type = T;
32+
using value_type = remove_cv_t<T>;
33+
using size_type = size_t;
34+
using difference_type = ptrdiff_t;
35+
using pointer = element_type*;
36+
using const_pointer = const element_type*;
37+
using reference = element_type&;
38+
using const_reference = const element_type&;
39+
using iterator = T*; // actual type is unspecified
40+
using const_iterator = const T*; // actual type is const_iterator<iterator>;
41+
using reverse_iterator = T*; // actual type is reverse_iterator<iterator>;
42+
using const_reverse_iterator = const T*; // actual type is const_iterator<reverse_iterator>;
43+
static constexpr size_type extent = Extent;
44+
45+
// constructor
46+
constexpr span() noexcept;
47+
48+
template<class It>
49+
constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
50+
51+
template<class It, class End>
52+
constexpr explicit(extent != dynamic_extent) span(It first, End last);
53+
54+
template<size_t N>
55+
constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
56+
57+
template<class U, size_t N>
58+
constexpr span(array<U, N>& arr) noexcept;
59+
60+
template<class U, size_t N>
61+
constexpr span(const array<U, N>& arr) noexcept;
62+
63+
template<class R>
64+
constexpr explicit(extent != dynamic_extent) span(R&& r);
65+
66+
constexpr span(const span& other) noexcept = default;
67+
68+
template<class OtherT, size_t OtherExtent>
69+
constexpr explicit span(const span<OtherT, OtherExtent>& s) noexcept;
70+
71+
~span() noexcept = default;
72+
73+
constexpr span& operator=(const span& other) noexcept = default;
74+
75+
// subviews
76+
template<size_t Count>
77+
constexpr span<element_type, Count> first() const;
78+
79+
template<size_t Count>
80+
constexpr span<element_type, Count> last() const;
81+
82+
template<size_t Offset, size_t Count = dynamic_extent>
83+
constexpr span<element_type, /* see description */> subspan() const;
84+
85+
constexpr span<element_type, dynamic_extent> first(size_type count) const;
86+
constexpr span<element_type, dynamic_extent> last(size_type count) const;
87+
constexpr span<element_type, dynamic_extent> subspan(size_type offset,
88+
size_type count = dynamic_extent) const;
89+
// observers
90+
constexpr size_type size() const noexcept;
91+
constexpr size_type size_bytes() const noexcept;
92+
[[nodiscard]] constexpr bool empty() const noexcept;
93+
94+
// element access
95+
constexpr reference operator[](size_type idx) const;
96+
constexpr reference front() const;
97+
constexpr reference back() const;
98+
constexpr pointer data() const noexcept;
99+
100+
// iterator support
101+
constexpr iterator begin() const noexcept;
102+
constexpr iterator end() const noexcept;
103+
constexpr const_iterator cbegin() const noexcept;
104+
constexpr const_iterator cend() const noexcept;
105+
constexpr reverse_iterator rbegin() const noexcept;
106+
constexpr reverse_iterator rend() const noexcept;
107+
constexpr const_reverse_iterator crbegin() const noexcept;
108+
constexpr const_reverse_iterator crend() const noexcept;
109+
};
110+
111+
template<class T, size_t N>
112+
span<const byte, N> as_bytes(span<T, N> s) noexcept;
113+
114+
template<class T, size_t N>
115+
span<byte, N> as_writable_bytes(span<T, N> s) noexcept
116+
117+
} // namespace std
118+
#endif
119+
120+
#endif // CPPREFERENCE_OSTREAM_H

headers/string

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,12 @@ public:
242242
CharT& back();
243243
const CharT& back() const;
244244
#endif
245+
245246
const CharT* data() const;
247+
#if CPPREFERENCE_STDVER >= 2017
248+
CharT* data();
249+
#endif
250+
246251
const CharT* c_str() const;
247252

248253
// iterators

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
premailer==3.7.0
2-
lxml==4.6.5
2+
lxml==4.9.1

0 commit comments

Comments
 (0)