C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches
anonymous_namespace{chapter-1.cpp} Namespace Reference

Classes

struct  test_result
 the container for test input and output. More...
 

Variables

struct {
   uint32_t   anonymous_namespace{chapter-1.cpp}::expected
 
   uint32_t   anonymous_namespace{chapter-1.cpp}::got
 
run []
 the container for test input and output.
 

Variable Documentation

◆ expected

uint32_t anonymous_namespace{chapter-1.cpp}::expected

Definition at line 58 of file c++20/chapter-1.cpp.

◆ got

uint32_t anonymous_namespace{chapter-1.cpp}::got

Definition at line 58 of file c++20/chapter-1.cpp.

◆ run

struct anonymous_namespace{chapter-1.cpp}::test_result anonymous_namespace{chapter-1.cpp}::run
Initial value:
= {
{.expected = 1, .got = binary(1)},
{.expected = 3, .got = binary(11)},
{.expected = 5, .got = binary(101)},
{.expected = 7, .got = binary(111)},
{.expected = 9, .got = binary(1001)},
}
consteval uint32_t binary(uint64_t const N)
Prepend higher bits to lowest bit.
Prepend higher bits to lowest bit.
Definition: chapter-1.cpp:47

the container for test input and output.

The book suggests making named constants in the global scope, but having a structure both allows me to add elements without much thought, and to use printf, which does one function call, instead of std::cout, which calls operator<< many times for various inputs.