cppx-core
fixed-size-checking.hpp
Go to the documentation of this file.
1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi").
2 
8 #include <cppx-core/language/syntax/macro-use.hpp> // CPPX_USE_STD
9 #include <cppx-core/language/syntax/type-assemblers.hpp> // cppx::(Raw_array_of_, P_)
11 #include <cppx-core/language/bit-level/bits_per_.hpp> // cppx::(bits_per_)
12 
13 #include <array> // std::array
14 #include <bitset> // std::bitset
15 #include <iterator> // std::(begin, end, size)
16 
17 namespace cppx
18 {
19  CPPX_USE_STD( array, bitset );
20 
21  using cppx::bits_per_;
22 
23  template< class Item, size_t n >
24  constexpr auto array_size_of( const Raw_array_of_<n, Item>& ) noexcept
25  -> Size
26  { return n; }
27 
28  template< class Item, size_t n >
29  constexpr auto array_size_of( const array<Item, n>& ) noexcept
30  -> Size
31  { return n; }
32 
33  template< class Item, size_t n >
34  constexpr auto array_size_of( const bitset<n>& ) noexcept
35  -> Size
36  { return n; }
37 
38  template< class Char, Size n >
39  constexpr inline auto length_of_literal( Raw_array_of_<n, const Char>& s ) noexcept
40  -> Size
41  { return n - 1; }
42 
43 } // namespace cppx
constexpr int bits_per_
The number of bits per object/value of the specified type.
Definition: bits_per_.hpp:22
bits_per_ and magnitude_bits_per_, plus the for-readability constant bits_per_byte.
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
Simple type builders Type_, P_, R_, Raw_array_ and Raw_array_of_.
constexpr auto length_of_literal(Raw_array_of_< n, const Char > &s) noexcept -> Size
Signed_< size_t > Size
A Signed_ equivalent of size_t.
constexpr auto array_size_of(const Raw_array_of_< n, Item > &) noexcept -> Size
Item[n] Raw_array_of_
Creates a raw array type of a specified size.
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...
Signed Size and Index, plus unsigned equivalents Unsigned_size and Unsigned_index.