Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah_errors_else_test.cc
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files (the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29*/
30
44# include <gtest/gtest.h>
45
46# include <new>
47# include <sstream>
48# include <stdexcept>
49# include <string>
50# include <type_traits>
51# include <utility>
52
53# include <ah-errors.H>
54# include <ah-trace.H>
55# include <parse_utils.H>
56
57# if defined(__clang__)
58# pragma clang diagnostic error "-Wdangling-else"
59// [[unlikely]] in a loop whose condition is constant, which Clang calls
60// infinite, has no effect, and Clang warns when it emits the code
61# pragma clang diagnostic error "-Wignored-attributes"
62# elif defined(__GNUC__)
63# pragma GCC diagnostic error "-Wdangling-else"
64# endif
65
66namespace
67{
68 int evaluations = 0; // of the conditions given to the macros
69
70 bool counted(bool value)
71 {
72 ++evaluations;
73 return value;
74 }
75
76 size_t occurrences(const std::string & text, const std::string & part)
77 {
78 size_t count = 0;
79 for (size_t pos = text.find(part); pos != std::string::npos;
80 pos = text.find(part, pos + part.size()))
81 ++count;
82 return count;
83 }
84}
85
86// MACRO throws E when its condition is THROWS, with TAIL after it. For each
87// value of the condition and of the if around the macro, the else after the
88// macro runs only when that if does not, the macro throws only from inside
89// that if, and the condition is evaluated once. Without the else, the same.
90# define TEST_THE_ELSE_AFTER(NAME, MACRO, E, THROWS, TAIL, HAS_MESSAGE) \
91 TEST(AhErrorsElse, NAME) \
92 { \
93 for (bool around : {false, true}) \
94 for (bool condition : {false, true}) \
95 { \
96 SCOPED_TRACE(testing::Message() << "around " << around \
97 << ", condition " << condition); \
98 bool else_ran = false; \
99 bool thrown = false; \
100 std::string what; \
101 evaluations = 0; \
102 try \
103 { \
104 if (around) \
105 MACRO(counted(condition)) TAIL; \
106 else \
107 else_ran = true; \
108 } \
109 catch (const E & e) \
110 { \
111 thrown = true; \
112 what = e.what(); \
113 } \
114 EXPECT_EQ(else_ran, not around); \
115 EXPECT_EQ(thrown, around and condition == THROWS); \
116 EXPECT_EQ(evaluations, around ? 1 : 0); \
117 if (thrown and HAS_MESSAGE) \
118 { \
119 EXPECT_EQ(occurrences(what, "ah_errors_else_test.cc:"), 1u) \
120 << what; \
121 EXPECT_EQ(occurrences(what, ") | the message"), 1u) << what; \
122 } \
123 \
124 thrown = false; \
125 evaluations = 0; \
126 try \
127 { \
128 if (around) \
129 MACRO(counted(condition)) TAIL; \
130 } \
131 catch (const E &) \
132 { \
133 thrown = true; \
134 } \
135 EXPECT_EQ(thrown, around and condition == THROWS); \
136 EXPECT_EQ(evaluations, around ? 1 : 0); \
137 } \
138 }
139
140// The same for the _constexpr form MACRO, which takes constant conditions
141# define TEST_THE_ELSE_AFTER_CONSTEXPR(NAME, MACRO, E, THROWS, TAIL) \
142 TEST(AhErrorsElse, NAME) \
143 { \
144 for (bool around : {false, true}) \
145 { \
146 SCOPED_TRACE(testing::Message() << "around " << around); \
147 bool else_ran = false; \
148 bool thrown = false; \
149 try \
150 { \
151 if (around) \
152 MACRO(THROWS) TAIL; \
153 else \
154 else_ran = true; \
155 } \
156 catch (const E &) \
157 { \
158 thrown = true; \
159 } \
160 EXPECT_EQ(else_ran, not around); \
161 EXPECT_EQ(thrown, around); \
162 \
163 else_ran = false; \
164 thrown = false; \
165 try \
166 { \
167 if (around) \
168 MACRO(not THROWS) TAIL; \
169 else \
170 else_ran = true; \
171 } \
172 catch (const E &) \
173 { \
174 thrown = true; \
175 } \
176 EXPECT_EQ(else_ran, not around); \
177 EXPECT_FALSE(thrown); \
178 \
179 thrown = false; \
180 try \
181 { \
182 if (around) \
183 MACRO(THROWS) TAIL; \
184 } \
185 catch (const E &) \
186 { \
187 thrown = true; \
188 } \
189 EXPECT_EQ(thrown, around); \
190 } \
191 }
192
193// The same for MACRO, which writes to its stream when its condition is
194// WRITES, and puts the location of the call first if LOCATED
195# define TEST_THE_ELSE_AFTER_A_MESSAGE(NAME, MACRO, WRITES, LOCATED) \
196 TEST(AhErrorsElse, NAME) \
197 { \
198 for (bool around : {false, true}) \
199 for (bool condition : {false, true}) \
200 { \
201 SCOPED_TRACE(testing::Message() << "around " << around \
202 << ", condition " << condition); \
203 const bool writes = around and condition == WRITES; \
204 std::ostringstream out; \
205 bool else_ran = false; \
206 evaluations = 0; \
207 if (around) \
208 MACRO(out, counted(condition)) << "the message"; \
209 else \
210 else_ran = true; \
211 EXPECT_EQ(else_ran, not around); \
212 EXPECT_EQ(evaluations, around ? 1 : 0); \
213 EXPECT_EQ(occurrences(out.str(), "the message"), writes ? 1u : 0u) \
214 << out.str(); \
215 if (writes and LOCATED) \
216 { \
217 EXPECT_EQ(occurrences(out.str(), "ah_errors_else_test.cc:"), \
218 1u) << out.str(); \
219 } \
220 \
221 std::ostringstream alone; \
222 evaluations = 0; \
223 if (around) \
224 MACRO(alone, counted(condition)) << "the message"; \
225 EXPECT_EQ(evaluations, around ? 1 : 0); \
226 EXPECT_EQ(occurrences(alone.str(), "the message"), \
227 writes ? 1u : 0u) << alone.str(); \
228 } \
229 }
230
231# define WITH_MESSAGE << "the message"
232# define WITHOUT_MESSAGE
233
234// ah-errors.H
235TEST_THE_ELSE_AFTER(RangeErrorIf, ah_range_error_if, std::range_error, true,
237TEST_THE_ELSE_AFTER(RangeErrorUnless, ah_range_error_unless, std::range_error,
238 false, WITH_MESSAGE, true)
239TEST_THE_ELSE_AFTER(RuntimeErrorIf, ah_runtime_error_if, std::runtime_error,
240 true, WITH_MESSAGE, true)
242 std::runtime_error, false, WITH_MESSAGE, true)
243TEST_THE_ELSE_AFTER(LogicErrorIf, ah_logic_error_if, std::logic_error, true,
245TEST_THE_ELSE_AFTER(LogicErrorUnless, ah_logic_error_unless, std::logic_error,
246 false, WITH_MESSAGE, true)
248 std::underflow_error, true, WITH_MESSAGE, true)
250 std::underflow_error, false, WITH_MESSAGE, true)
252 std::overflow_error, true, WITH_MESSAGE, true)
254 std::overflow_error, false, WITH_MESSAGE, true)
255TEST_THE_ELSE_AFTER(DomainErrorIf, ah_domain_error_if, std::domain_error,
256 true, WITH_MESSAGE, true)
258 std::domain_error, false, WITH_MESSAGE, true)
260 std::out_of_range, true, WITH_MESSAGE, true)
262 std::out_of_range, false, WITH_MESSAGE, true)
264 std::invalid_argument, true, WITH_MESSAGE, true)
266 std::invalid_argument, false, WITH_MESSAGE, true)
267TEST_THE_ELSE_AFTER(LengthErrorIf, ah_length_error_if, std::length_error,
268 true, WITH_MESSAGE, true)
270 std::length_error, false, WITH_MESSAGE, true)
271TEST_THE_ELSE_AFTER(BadAllocIf, ah_bad_alloc_if, std::bad_alloc, true,
273TEST_THE_ELSE_AFTER(BadAllocUnless, ah_bad_alloc_unless, std::bad_alloc,
274 false, WITHOUT_MESSAGE, false)
275
276TEST_THE_ELSE_AFTER_CONSTEXPR(RangeErrorIfConstexpr,
277 ah_range_error_if_constexpr, std::range_error,
279TEST_THE_ELSE_AFTER_CONSTEXPR(RangeErrorUnlessConstexpr,
281 std::range_error, false, WITH_MESSAGE)
282TEST_THE_ELSE_AFTER_CONSTEXPR(RuntimeErrorIfConstexpr,
284 std::runtime_error, true, WITH_MESSAGE)
285TEST_THE_ELSE_AFTER_CONSTEXPR(RuntimeErrorUnlessConstexpr,
287 std::runtime_error, false, WITH_MESSAGE)
288TEST_THE_ELSE_AFTER_CONSTEXPR(LogicErrorIfConstexpr,
289 ah_logic_error_if_constexpr, std::logic_error,
291TEST_THE_ELSE_AFTER_CONSTEXPR(LogicErrorUnlessConstexpr,
293 std::logic_error, false, WITH_MESSAGE)
294TEST_THE_ELSE_AFTER_CONSTEXPR(UnderflowErrorIfConstexpr,
296 std::underflow_error, true, WITH_MESSAGE)
297TEST_THE_ELSE_AFTER_CONSTEXPR(UnderflowErrorUnlessConstexpr,
299 std::underflow_error, false, WITH_MESSAGE)
300TEST_THE_ELSE_AFTER_CONSTEXPR(OverflowErrorIfConstexpr,
302 std::overflow_error, true, WITH_MESSAGE)
303TEST_THE_ELSE_AFTER_CONSTEXPR(OverflowErrorUnlessConstexpr,
305 std::overflow_error, false, WITH_MESSAGE)
306TEST_THE_ELSE_AFTER_CONSTEXPR(DomainErrorIfConstexpr,
307 ah_domain_error_if_constexpr, std::domain_error,
309TEST_THE_ELSE_AFTER_CONSTEXPR(DomainErrorUnlessConstexpr,
311 std::domain_error, false, WITH_MESSAGE)
312TEST_THE_ELSE_AFTER_CONSTEXPR(OutOfRangeErrorIfConstexpr,
314 std::out_of_range, true, WITH_MESSAGE)
315TEST_THE_ELSE_AFTER_CONSTEXPR(OutOfRangeErrorUnlessConstexpr,
317 std::out_of_range, false, WITH_MESSAGE)
318TEST_THE_ELSE_AFTER_CONSTEXPR(InvalidArgumentIfConstexpr,
320 std::invalid_argument, true, WITH_MESSAGE)
321TEST_THE_ELSE_AFTER_CONSTEXPR(InvalidArgumentUnlessConstexpr,
323 std::invalid_argument, false, WITH_MESSAGE)
324TEST_THE_ELSE_AFTER_CONSTEXPR(LengthErrorIfConstexpr,
325 ah_length_error_if_constexpr, std::length_error,
327TEST_THE_ELSE_AFTER_CONSTEXPR(LengthErrorUnlessConstexpr,
329 std::length_error, false, WITH_MESSAGE)
331 std::bad_alloc, true, WITHOUT_MESSAGE)
332TEST_THE_ELSE_AFTER_CONSTEXPR(BadAllocUnlessConstexpr,
335
338
339// parse_utils.H
344
345// ah-trace.H
350
351namespace
352{
353 int chain(int k, int x)
354 {
355 int r = 0;
356 if (k == 0)
357 ah_domain_error_if(x < 0) << "x is negative";
358 else if (k == 1)
359 ah_domain_error_unless(x > 0) << "x is not positive";
360 else
361 r = 2;
362 return r;
363 }
364}
365
366TEST(AhErrorsElse, ElseIfChain)
367{
368 EXPECT_EQ(chain(0, 1), 0);
369 EXPECT_THROW(chain(0, -1), std::domain_error);
370 EXPECT_EQ(chain(1, 1), 0);
371 EXPECT_THROW(chain(1, 0), std::domain_error);
372 EXPECT_EQ(chain(2, -5), 2);
373}
374
375// A break or a continue after a macro is that of the switch or the loop of
376// the caller
377TEST(AhErrorsElse, BreakAndContinueAfterAMacro)
378{
379 int r = 0;
380 for (int i = 0; i < 6; ++i)
381 {
382 switch (i % 3)
383 {
384 case 0:
385 ah_domain_error_if(i < 0) << "never";
386 r += 1;
387 break;
388 default:
389 ah_domain_error_unless(i >= 0) << "never";
390 if (i == 4)
391 continue;
392 r += 10;
393 }
394 r += 100;
395 }
396 EXPECT_EQ(r, 1 + 100 + 2 * (10 + 100) + 1 + 100 + 10 + 100);
397}
398
399namespace
400{
401 template <class T>
402 int not_a_pointer(bool checked)
403 {
404 if (checked)
405 ah_invalid_argument_if_constexpr(std::is_pointer_v<T>) << "a pointer";
406 else
407 return 2;
408 return 1;
409 }
410}
411
412TEST(AhErrorsElse, ConstexprFormInATemplate)
413{
414 EXPECT_EQ(not_a_pointer<int>(false), 2);
415 EXPECT_EQ(not_a_pointer<int>(true), 1);
416 EXPECT_EQ(not_a_pointer<int *>(false), 2);
417 EXPECT_THROW(not_a_pointer<int *>(true), std::invalid_argument);
418}
419
420// The variable of the loop of the macros that write, which was named
421// ah_warning_once_, ah_trace_once_ or ah_msg_once_, hides no name of the
422// caller: neither one in the condition, which initialized the variable with
423// itself, nor the stream
424TEST(AhErrorsElse, TheMacrosThatWriteHideNoNameOfTheCaller)
425{
426 {
427 const bool ah_warning_once_ = true;
428 const bool ah_trace_once_ = true;
429 const bool ah_msg_once_ = true;
430 std::ostringstream out;
431 ah_warning_if(out, ah_warning_once_) << "<1>";
432 ah_warning_unless(out, not ah_warning_once_) << "<2>";
433 ah_trace_if(out, ah_trace_once_) << "<3>";
434 ah_trace_unless(out, not ah_trace_once_) << "<4>";
435 ah_msg_if(out, ah_msg_once_) << "<5>";
436 ah_msg_unless(out, not ah_msg_once_) << "<6>";
437 for (const char * part : {"<1>", "<2>", "<3>", "<4>", "<5>", "<6>"})
438 {
439 EXPECT_EQ(occurrences(out.str(), part), 1u) << part << ": "
440 << out.str();
441 }
442 }
443
444 std::ostringstream ah_warning_once_, ah_trace_once_, ah_msg_once_;
445 ah_warning_if(ah_warning_once_, true) << "<w>";
446 ah_trace_if(ah_trace_once_, true) << "<t>";
447 ah_msg_if(ah_msg_once_, true) << "<m>";
448 EXPECT_EQ(occurrences(ah_warning_once_.str(), "<w>"), 1u);
449 EXPECT_EQ(occurrences(ah_trace_once_.str(), "<t>"), 1u);
450 EXPECT_EQ(occurrences(ah_msg_once_.str(), "<m>"), 1u);
451}
452
453// The variable of the loop of the macros that throw hides no name of the
454// caller in the condition, which would initialize the variable with itself
455TEST(AhErrorsElse, TheMacrosThatThrowHideNoNameOfTheCaller)
456{
457 const bool ah_error_once_ = true;
458 EXPECT_THROW(ah_domain_error_if(ah_error_once_) << "<1>", std::domain_error);
459 EXPECT_THROW(ah_domain_error_unless(not ah_error_once_) << "<2>",
460 std::domain_error);
461 EXPECT_THROW(ah_parse_error_if(ah_error_once_) << "<3>", Aleph::ParseError);
462 EXPECT_NO_THROW(ah_domain_error_if(not ah_error_once_) << "<4>");
463}
464
465namespace
466{
467 // Constant conditions, and functions that the compiler emits with them
468 constexpr bool always = true;
469
470 template <int N>
471 int positive()
472 {
473 ah_invalid_argument_if(N <= 0) << "N is " << N;
474 ah_invalid_argument_unless(N > 0) << "N is " << N;
475 return N;
476 }
477
478 int with_constant_conditions(int k)
479 {
480 if (k == 0)
481 ah_domain_error_if(true) << "k is 0";
482 if (k == 1)
483 ah_domain_error_unless(false) << "k is 1";
484 if (k == 2)
485 ah_runtime_error_if(always) << "k is 2";
486 if (k == 3)
487 ah_parse_error_if(true) << "k is 3";
488 if (k == 4)
489 ah_parse_error_unless(false) << "k is 4";
490 if (k == 5)
491 return positive<0>();
492 return positive<1>();
493 }
494}
495
496// The macros that throw were a while with [[unlikely]], and Clang warned,
497// as -Wignored-attributes does by default, that the attribute has no effect
498// on a loop whose condition is constant
499TEST(AhErrorsElse, ConstantConditionsDoNotWarn)
500{
501 EXPECT_THROW(with_constant_conditions(0), std::domain_error);
502 EXPECT_THROW(with_constant_conditions(1), std::domain_error);
503 EXPECT_THROW(with_constant_conditions(2), std::runtime_error);
504 EXPECT_THROW(with_constant_conditions(3), Aleph::ParseError);
505 EXPECT_THROW(with_constant_conditions(4), Aleph::ParseError);
506 EXPECT_THROW(with_constant_conditions(5), std::invalid_argument);
507 EXPECT_EQ(with_constant_conditions(6), 1);
508}
509
510namespace
511{
512 enum Check_Flags : unsigned { Checked = 1u << 1 };
513
514 // A constant that converts to bool only explicitly
515 struct Enabled
516 {
517 bool on;
518
519 constexpr explicit operator bool() const noexcept { return on; }
520 };
521
522 template <unsigned F>
523 int masked(int x)
524 {
525 ah_domain_error_if_constexpr(F & Checked) << "checked";
526 return x;
527 }
528
529 template <bool B>
530 int enabled(int x)
531 {
532 ah_invalid_argument_if_constexpr(Enabled{not B}) << "disabled";
533 return x;
534 }
535}
536
537// The _constexpr forms gave their condition to std::bool_constant, which
538// takes neither a narrowing conversion, as that of 2 to bool, nor an
539// explicit one; if constexpr takes both
540TEST(AhErrorsElse, ConstexprFormsConvertTheirConditionAsIfConstexpr)
541{
542 EXPECT_THROW(masked<Checked>(1), std::domain_error);
543 EXPECT_EQ(masked<0>(10), 10);
544 EXPECT_THROW(enabled<false>(1), std::invalid_argument);
545 EXPECT_EQ(enabled<true>(100), 100);
546}
547
548namespace
549{
550 // An indentation, whose << gives back a wrapper of the stream
551 struct Indent
552 {
553 int width;
554 };
555
556 struct Indented
557 {
558 std::ostream & out;
559
560 operator std::ostream & () const { return out; }
561 };
562
563 Indented operator << (std::ostream & out, const Indent & indent)
564 {
565 out << std::string(indent.width, ' ');
566 return Indented{out};
567 }
568
569 // What a message gives back when its last << does not give back a stream
570 struct Not_A_Stream {};
571
572 template <class Tail>
573 constexpr bool throws_with = requires (Tail && tail)
574 {
575 Aleph::ExceptionBuilder<std::domain_error>() <<= std::forward<Tail>(tail);
576 };
577
578 template <class F>
579 constexpr bool throws_with_the_result_of = requires (F f)
580 {
582 };
583}
584
585// The operator that throws takes a stream, or what converts to one; a
586// message whose last << gives back something else, as void, does not
587// compile, since it would not reach the operator. The comma, with its
588// built-in version, took a void and threw nothing.
589static_assert(throws_with<std::ostringstream &>);
590static_assert(throws_with<std::ostringstream &&>);
591static_assert(throws_with<std::ostream &>);
592static_assert(throws_with<Indented>);
593static_assert(not throws_with<Not_A_Stream>);
594static_assert(not throws_with<int>);
595static_assert(not throws_with<const char *>);
596static_assert(not throws_with_the_result_of<void (*)()>);
597
598// The comma that threw was deleted for what does not derive from a stream,
599// so a message that gave back a wrapper that converts to the stream did
600// not compile
601TEST(AhErrorsElse, AMessageThatGivesBackAWrapperOfTheStreamIsThrown)
602{
603 std::string what;
604 try
605 {
606 ah_domain_error_if(counted(true)) << "first line" << std::endl
607 << Indent{2};
608 }
609 catch (const std::domain_error & e)
610 {
611 what = e.what();
612 }
613 EXPECT_NE(what.find(") | first line\n "), std::string::npos) << what;
614}
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if_constexpr(C)
Definition ah-errors.H:705
#define ah_invalid_argument_unless_constexpr(C)
Definition ah-errors.H:827
#define ah_overflow_error_unless_constexpr(C)
Definition ah-errors.H:651
#define ah_runtime_error_if_constexpr(C)
Definition ah-errors.H:435
#define ah_length_error_unless_constexpr(C)
Definition ah-errors.H:886
#define ah_overflow_error_unless(C)
Throws std::overflow_error if condition does NOT hold.
Definition ah-errors.H:627
#define ah_runtime_error_unless(C)
Throws std::runtime_error if condition does NOT hold.
Definition ah-errors.H:399
#define ah_bad_alloc_unless_constexpr(C)
Definition ah-errors.H:593
#define ah_length_error_if(C)
Throws std::length_error if condition holds.
Definition ah-errors.H:846
#define ah_logic_error_unless_constexpr(C)
Definition ah-errors.H:498
#define ah_domain_error_unless(C)
Throws std::domain_error if condition does NOT hold.
Definition ah-errors.H:686
#define ah_range_error_if_constexpr(C)
Definition ah-errors.H:376
#define ah_domain_error_unless_constexpr(C)
Definition ah-errors.H:708
#define ah_out_of_range_error_if_constexpr(C)
Definition ah-errors.H:763
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
Definition ah-errors.H:727
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
Definition ah-errors.H:517
#define ah_underflow_error_unless_constexpr(C)
Definition ah-errors.H:557
#define ah_out_of_range_error_unless(C)
Throws std::out_of_range if condition does NOT hold.
Definition ah-errors.H:743
#define ah_bad_alloc_unless(C)
Throws std::bad_alloc if condition does NOT hold.
Definition ah-errors.H:587
#define ah_bad_alloc_if_constexpr(C)
Definition ah-errors.H:590
#define ah_range_error_unless_constexpr(C)
Definition ah-errors.H:380
#define ah_logic_error_unless(C)
Throws std::logic_error if condition does NOT hold.
Definition ah-errors.H:458
#define ah_out_of_range_error_unless_constexpr(C)
Definition ah-errors.H:767
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
Definition ah-errors.H:611
#define ah_runtime_error_unless_constexpr(C)
Definition ah-errors.H:439
#define ah_warning_if(out, C)
Emits a warning to a stream if the condition holds.
Definition ah-errors.H:305
#define ah_overflow_error_if_constexpr(C)
Definition ah-errors.H:647
#define ah_invalid_argument_unless(C)
Throws std::invalid_argument if condition does NOT hold.
Definition ah-errors.H:803
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Definition ah-errors.H:670
#define ah_underflow_error_if_constexpr(C)
Definition ah-errors.H:553
#define ah_logic_error_if(C)
Throws std::logic_error if condition holds.
Definition ah-errors.H:474
#define ah_length_error_unless(C)
Throws std::length_error if condition does NOT hold.
Definition ah-errors.H:862
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
Definition ah-errors.H:415
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
Definition ah-errors.H:787
#define ah_range_error_unless(C)
Throws std::range_error if condition does NOT hold.
Definition ah-errors.H:340
#define ah_bad_alloc_if(C)
Throws std::bad_alloc if condition holds.
Definition ah-errors.H:578
#define ah_logic_error_if_constexpr(C)
Definition ah-errors.H:494
#define ah_length_error_if_constexpr(C)
Definition ah-errors.H:882
#define ah_underflow_error_unless(C)
Throws std::underflow_error if condition does NOT hold.
Definition ah-errors.H:533
#define ah_invalid_argument_if_constexpr(C)
Definition ah-errors.H:823
#define ah_warning_unless(out, C)
Emits a warning to a stream if the condition does NOT hold.
Definition ah-errors.H:288
#define ah_range_error_if(C)
Throws std::range_error if condition holds.
Definition ah-errors.H:356
Conditional tracing macros for debugging.
#define ah_msg_if(out, C)
Definition ah-trace.H:76
#define ah_msg_unless(out, C)
Definition ah-trace.H:81
#define ah_trace_unless(out, C)
Definition ah-trace.H:63
#define ah_trace_if(out, C)
Definition ah-trace.H:68
#define WITH_MESSAGE
#define TEST_THE_ELSE_AFTER(NAME, MACRO, E, THROWS, TAIL, HAS_MESSAGE)
#define TEST_THE_ELSE_AFTER_CONSTEXPR(NAME, MACRO, E, THROWS, TAIL)
#define WITHOUT_MESSAGE
#define TEST_THE_ELSE_AFTER_A_MESSAGE(NAME, MACRO, WRITES, LOCATED)
size_t size_t int32_t value
Definition ca-c-api.h:116
size_t size_t int32_t * out
Definition ca-c-api.h:120
Number Theoretic Transform over Z / MOD Z.
Definition ntt.H:115
Exception class for parsing errors with location information.
#define TEST(name)
#define N
Definition fib.C:294
static Tree_Node< int > * chain(size_t n)
std::string indent(const size_t count)
constexpr Word masked(Next &&next, const Word n) noexcept(noexcept(next()))
An integer in [0, n), each with the same probability, from numbers of the bits of Word,...
Definition ah-random.H:799
Main namespace for Aleph-w library functions.
std::ostream & operator<<(std::ostream &osObject, const Field< T > &rightOp)
Definition ahField.H:121
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Definition ahAlgo.H:127
STL namespace.
Comprehensive parsing utilities for text processing and compiler construction.
#define ah_parse_error_if(C)
Throws a ParseError if condition holds.
#define ah_parse_error_unless(C)
Throws a ParseError if condition does NOT hold.
Exception constructor with formatted message.
Definition ah-errors.H:226
static int * k
Gsl_Compatible_Rng r