Skip to content

Commit b103cba

Browse files
committed
docs(reference): mrdocs comments
partial progress toward #1102
1 parent 9b7ec24 commit b103cba

File tree

197 files changed

+5178
-1036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+5178
-1036
lines changed

.github/workflows/ci.yml

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,23 @@ concurrency:
2020
jobs:
2121
cpp-matrix:
2222
runs-on: ubuntu-24.04
23+
container:
24+
image: ubuntu:24.04
2325
name: Generate Test Matrix
2426
outputs:
2527
matrix: ${{ steps.cpp-matrix.outputs.matrix }}
2628
llvm-matrix: ${{ steps.llvm-matrix.outputs.llvm-matrix }}
2729
releases-matrix: ${{ steps.releases-matrix.outputs.releases-matrix }}
2830
steps:
31+
- name: Install prerequisites
32+
run: |
33+
set -e
34+
apt-get update
35+
apt-get install -y git ca-certificates curl nodejs npm
36+
if ! command -v node >/dev/null 2>&1 && command -v nodejs >/dev/null 2>&1; then
37+
ln -s /usr/bin/nodejs /usr/bin/node
38+
fi
39+
2940
- name: Checkout
3041
uses: actions/checkout@v4
3142

@@ -134,6 +145,16 @@ jobs:
134145
contents: write
135146

136147
steps:
148+
- name: Ensure Node
149+
if: matrix.container != '' && env.ACT == 'true'
150+
run: |
151+
set -e
152+
apt-get update
153+
apt-get install -y nodejs npm
154+
if ! command -v node >/dev/null 2>&1 && command -v nodejs >/dev/null 2>&1; then
155+
ln -s /usr/bin/nodejs /usr/bin/node
156+
fi
157+
137158
# We install git if we are using a container because
138159
# containers don't always include git.
139160
# We need git to ensure actions/checkout@v4 will use git and
@@ -174,6 +195,55 @@ jobs:
174195
compiler: ${{ matrix.compiler }}
175196
version: ${{ matrix.version }}
176197

198+
- name: Configure symbolizer paths
199+
if: matrix.compiler != 'msvc'
200+
shell: bash
201+
run: |
202+
set -e
203+
candidates=()
204+
# 1) Anything on PATH
205+
if command -v llvm-symbolizer >/dev/null 2>&1; then
206+
candidates+=("$(command -v llvm-symbolizer)")
207+
fi
208+
uname_out="$(uname -s || true)"
209+
# 2) Platform-specific common locations
210+
case "$uname_out" in
211+
Darwin)
212+
if xcrun --find llvm-symbolizer >/dev/null 2>&1; then
213+
candidates+=("$(xcrun --find llvm-symbolizer)")
214+
fi
215+
candidates+=("/opt/homebrew/opt/llvm/bin/llvm-symbolizer")
216+
;;
217+
Linux)
218+
for dir in /usr/lib/llvm-* /usr/lib/llvm; do
219+
if [ -x "$dir/bin/llvm-symbolizer" ]; then
220+
candidates+=("$dir/bin/llvm-symbolizer")
221+
fi
222+
done
223+
;;
224+
MINGW*|MSYS*|CYGWIN*)
225+
for dir in "/c/Program Files/LLVM/bin" "/c/ProgramData/chocolatey/lib/llvm/tools/llvm/bin"; do
226+
if [ -x "$dir/llvm-symbolizer.exe" ]; then
227+
candidates+=("$dir/llvm-symbolizer.exe")
228+
fi
229+
done
230+
;;
231+
esac
232+
sym=""
233+
for c in "${candidates[@]}"; do
234+
if [ -n "$c" ] && [ -x "$c" ]; then
235+
sym="$c"
236+
break
237+
fi
238+
done
239+
if [ -n "$sym" ]; then
240+
echo "Using llvm-symbolizer at: $sym"
241+
echo "LLVM_SYMBOLIZER_PATH=$sym" >> "$GITHUB_ENV"
242+
echo "ASAN_SYMBOLIZER_PATH=$sym" >> "$GITHUB_ENV"
243+
else
244+
echo "Warning: llvm-symbolizer not found; ASan stacks may be unsymbolized." >&2
245+
fi
246+
177247
# If apple-clang on macos, select the newest Xcode.
178248
- name: Select Xcode 16.4
179249
if: matrix.compiler == 'apple-clang'
@@ -484,6 +554,9 @@ jobs:
484554

485555
- name: CMake Workflow
486556
uses: alandefreitas/cpp-actions/[email protected]
557+
env:
558+
# Bump per-test timeout on Windows to avoid CTest default (1500s) killing slow golden suites.
559+
CTEST_TEST_TIMEOUT: ${{ runner.os == 'Windows' && '3600' || '' }}
487560
with:
488561
cmake-version: '>=3.26'
489562
cxxstd: ${{ matrix.cxxstd }}
@@ -619,8 +692,9 @@ jobs:
619692
done
620693
621694
dir="./build"
622-
lcov --rc lcov_branch_coverage=0 --gcov-tool "$gcov_tool" --directory "$dir" --capture --output-file "$dir/all.info" --ignore-errors inconsistent
623-
lcov --rc lcov_branch_coverage=0 --ignore-errors inconsistent --list "$dir/all.info"
695+
lcov --rc lcov_branch_coverage=0 --gcov-tool "$gcov_tool" --directory "$dir" --capture --output-file "$dir/all.info" --ignore-errors inconsistent,negative --no-external
696+
lcov --rc lcov_branch_coverage=0 --remove "$dir/all.info" "/usr/*" "/lib/*" "/opt/*" --ignore-errors unused,negative --output-file "$dir/all.info"
697+
lcov --rc lcov_branch_coverage=0 --ignore-errors inconsistent,negative --list "$dir/all.info"
624698
echo "file=$(realpath "$dir/all.info")" >> $GITHUB_OUTPUT
625699
626700
- name: Upload Coverage as Artifact
@@ -661,6 +735,16 @@ jobs:
661735
contents: write
662736

663737
steps:
738+
- name: Ensure Node
739+
if: matrix.container != '' && env.ACT == 'true'
740+
run: |
741+
set -e
742+
apt-get update
743+
apt-get install -y nodejs npm
744+
if ! command -v node >/dev/null 2>&1 && command -v nodejs >/dev/null 2>&1; then
745+
ln -s /usr/bin/nodejs /usr/bin/node
746+
fi
747+
664748
- name: Install packages
665749
uses: alandefreitas/cpp-actions/[email protected]
666750
id: package-install
@@ -1117,6 +1201,16 @@ jobs:
11171201
contents: write
11181202

11191203
steps:
1204+
- name: Ensure Node
1205+
if: matrix.container != '' && env.ACT == 'true'
1206+
run: |
1207+
set -e
1208+
apt-get update
1209+
apt-get install -y nodejs npm
1210+
if ! command -v node >/dev/null 2>&1 && command -v nodejs >/dev/null 2>&1; then
1211+
ln -s /usr/bin/nodejs /usr/bin/node
1212+
fi
1213+
11201214
# This calculates a couple of variables, which would normally go in to the regular matrix extra-values
11211215
# section, but which depend on paths not known at that point.
11221216
- name: Resolved Matrix

include/mrdocs/ADT/ArrayView.hpp

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,94 +33,200 @@ class ArrayView {
3333

3434
public:
3535
// types
36+
/** Element type referenced by the view.
37+
*/
3638
using value_type = T;
39+
/** Unsigned size type.
40+
*/
3741
using size_type = std::size_t;
42+
/** Signed iterator difference type.
43+
*/
3844
using difference_type = std::ptrdiff_t;
45+
/** Pointer to constant element.
46+
*/
3947
using pointer = const T*;
48+
/** Pointer to constant element.
49+
*/
4050
using const_pointer = const T*;
51+
/** Reference to constant element.
52+
*/
4153
using reference = const T&;
54+
/** Reference to constant element.
55+
*/
4256
using const_reference = const T&;
57+
/** Iterator over elements.
58+
*/
4359
using iterator = const T*;
60+
/** Iterator over elements.
61+
*/
4462
using const_iterator = const T*;
63+
/** Reverse iterator over the view.
64+
*/
4565
using reverse_iterator = std::reverse_iterator<const_iterator>;
66+
/** Const reverse iterator over the view.
67+
*/
4668
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
4769

70+
/** Sentinel used by slicing helpers to indicate “until the end”.
71+
*/
4872
static constexpr size_type npos = static_cast<size_type>(-1);
4973

5074
// ctors
75+
/** Construct an empty view.
76+
*/
5177
constexpr ArrayView() noexcept = default;
5278

79+
/** Construct a view from a pointer and element count.
80+
@param data Pointer to the first element.
81+
@param count Number of elements in the range.
82+
*/
5383
constexpr ArrayView(const T* data, size_type count) noexcept
5484
: data_(data), size_(count) {}
5585

86+
/** Construct a view from a C-style array.
87+
@param arr The array to view.
88+
*/
5689
template <size_type N>
5790
constexpr ArrayView(const T (&arr)[N]) noexcept
5891
: data_(arr), size_(N) {}
5992

93+
/** Construct a view from a contiguous iterator range of known size.
94+
@param first Iterator to the first element.
95+
@param count Number of elements starting at `first`.
96+
*/
6097
template <class It>
6198
requires (std::contiguous_iterator<It> &&
6299
std::same_as<std::remove_cv_t<std::remove_reference_t<std::iter_value_t<It>>>, T>)
63100
constexpr ArrayView(It first, size_type count) noexcept
64101
: data_(std::to_address(first)), size_(count) {}
65102

66103
// iterators
104+
/** Return an iterator to the first element.
105+
@return Iterator to the start of the view.
106+
*/
67107
constexpr const_iterator begin() const noexcept { return data_; }
108+
/** Return an iterator one past the last element.
109+
@return Iterator to the end sentinel.
110+
*/
68111
constexpr const_iterator end() const noexcept { return data_ + size_; }
112+
/** Return a const iterator to the first element.
113+
@return Const iterator to the start of the view.
114+
*/
69115
constexpr const_iterator cbegin() const noexcept { return begin(); }
116+
/** Return a const iterator one past the last element.
117+
@return Const iterator to the end sentinel.
118+
*/
70119
constexpr const_iterator cend() const noexcept { return end(); }
120+
/** Return a reverse iterator to the last element.
121+
@return Reverse iterator to the last element.
122+
*/
71123
constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
124+
/** Return a reverse iterator one before the first element.
125+
@return Reverse iterator denoting the rend sentinel.
126+
*/
72127
constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
73128

74129
// capacity
130+
/** Return the number of elements in the view.
131+
@return Element count.
132+
*/
75133
constexpr size_type size() const noexcept { return size_; }
134+
/** Return the number of elements in the view.
135+
@return Element count.
136+
*/
76137
constexpr size_type length() const noexcept { return size_; }
138+
/** Return true if the view contains no elements.
139+
@return `true` when size is zero, otherwise `false`.
140+
*/
77141
[[nodiscard]] constexpr bool empty() const noexcept { return size_ == 0; }
78142

79143
// element access
144+
/** Access the element at the specified index without bounds checking.
145+
@param i Zero-based index.
146+
@return Reference to the element.
147+
*/
80148
constexpr const_reference operator[](size_type i) const noexcept {
81149
return data_[i];
82150
}
151+
/** Access the element at the specified index with bounds checking.
152+
@param i Zero-based index.
153+
@return Reference to the element.
154+
*/
83155
constexpr const_reference at(size_type i) const {
84156
assert(i < size_);
85157
return data_[i];
86158
}
159+
/** Return a reference to the first element.
160+
*/
87161
constexpr const_reference front() const {
88162
assert(!empty());
89163
return data_[0];
90164
}
165+
/** Return a reference to the last element.
166+
*/
91167
constexpr const_reference back() const {
92168
assert(!empty());
93169
return data_[size_ - 1];
94170
}
171+
/** Return a pointer to the underlying data.
172+
@return Pointer to the first element, or nullptr when empty.
173+
*/
95174
constexpr const_pointer data() const noexcept { return data_; }
96175

97176
// modifiers (adjust the view; do not touch underlying data)
177+
/** Remove `n` elements from the front of the view.
178+
@param n Number of elements to drop.
179+
*/
98180
constexpr void remove_prefix(size_type n) noexcept {
99181
assert(n <= size_);
100182
data_ += n;
101183
size_ -= n;
102184
}
185+
/** Remove `n` elements from the back of the view.
186+
@param n Number of elements to drop.
187+
*/
103188
constexpr void remove_suffix(size_type n) noexcept {
104189
assert(n <= size_);
105190
size_ -= n;
106191
}
107192

108193
// slicing
194+
/** Return a subview starting at `pos` with up to `count` elements.
195+
@param pos Starting index within the current view.
196+
@param count Maximum number of elements to include; use npos for the remainder.
197+
@return Subview representing the requested slice.
198+
*/
109199
constexpr ArrayView slice(size_type pos, size_type count = npos) const noexcept {
110200
assert(pos <= size_);
111201
const size_type rcount = (count == npos || pos + count > size_) ? (size_ - pos) : count;
112202
return ArrayView(data_ + pos, rcount);
113203
}
204+
/** Return a view containing the first `n` elements.
205+
@param n Desired prefix length.
206+
@return Subview of the first `n` elements (clamped to size).
207+
*/
114208
constexpr ArrayView take_front(size_type n) const noexcept {
115209
return slice(0, n <= size_ ? n : size_);
116210
}
211+
/** Return a view containing the last `n` elements.
212+
@param n Desired suffix length.
213+
@return Subview of the last `n` elements (clamped to size).
214+
*/
117215
constexpr ArrayView take_back(size_type n) const noexcept {
118216
n = (n <= size_) ? n : size_;
119217
return slice(size_ - n, n);
120218
}
219+
/** Return a view with the first `n` elements removed.
220+
@param n Number of elements to drop from the front.
221+
@return Subview starting after the dropped elements.
222+
*/
121223
constexpr ArrayView drop_front(size_type n) const noexcept {
122224
return (n >= size_) ? ArrayView() : ArrayView(data_ + n, size_ - n);
123225
}
226+
/** Return a view with the last `n` elements removed.
227+
@param n Number of elements to drop from the back.
228+
@return Subview excluding the dropped elements.
229+
*/
124230
constexpr ArrayView drop_back(size_type n) const noexcept {
125231
return (n >= size_) ? ArrayView() : ArrayView(data_, size_ - n);
126232
}
@@ -145,18 +251,31 @@ class ArrayView {
145251
};
146252

147253
// deduction guides
254+
/** Deduce ArrayView element type from pointer and count.
255+
*/
148256
template <class T>
149257
ArrayView(const T*, std::size_t) -> ArrayView<T>;
150258

259+
/** Deduce ArrayView element type from C-style array.
260+
*/
151261
template <class T, std::size_t N>
152262
ArrayView(const T (&)[N]) -> ArrayView<T>;
153263

154264
// helpers
265+
/** Create an ArrayView from a pointer and count.
266+
@param data Pointer to the first element.
267+
@param count Number of elements.
268+
@return View over the provided range.
269+
*/
155270
template <class T>
156271
constexpr ArrayView<T> make_array_view(const T* data, std::size_t count) noexcept {
157272
return ArrayView<T>(data, count);
158273
}
159274

275+
/** Create an ArrayView from a C-style array.
276+
@param arr Array to view.
277+
@return View over the provided array.
278+
*/
160279
template <class T, std::size_t N>
161280
constexpr ArrayView<T> make_array_view(const T (&arr)[N]) noexcept {
162281
return ArrayView<T>(arr);

0 commit comments

Comments
 (0)