OpenKalman
size_of.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2024-2025 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_COLLECTIONS_SIZE_OF_HPP
17 #define OPENKALMAN_COLLECTIONS_SIZE_OF_HPP
18 
19 #include "values/values.hpp"
22 
24 {
28 #ifdef __cpp_concepts
29  template<typename T>
30 #else
31  template<typename T, typename = void>
32 #endif
33  struct size_of {};
34 
35 
36 #ifdef __cpp_concepts
37  template<sized T>
38  struct size_of<T>
39 #else
40  template<typename T>
41  struct size_of<T, std::enable_if_t<sized<T> and not values::fixed<decltype(collections::get_size(std::declval<T>()))>>>
42 #endif
43  : std::integral_constant<std::size_t, stdex::dynamic_extent> {};
44 
45 
46 #ifdef __cpp_concepts
47  template<sized T> requires values::fixed<decltype(collections::get_size(std::declval<T>()))>
48  struct size_of<T>
49 #else
50  template<typename T>
51  struct size_of<T, std::enable_if_t<sized<T> and values::fixed<decltype(collections::get_size(std::declval<T>()))>>>
52 #endif
54 
55 
59  template<typename T>
60  inline constexpr std::size_t size_of_v = size_of<T>::value;
61 
62 }
63 
64 #endif
Namespace for collections.
Definition: collections.hpp:27
Header file for code relating to values (e.g., scalars and indices)
The size of a sized object (including a collection).
Definition: size_of.hpp:33
The fixed value associated with a fixed.
Definition: fixed_value_of.hpp:44
Definition for collections::sized.
Definition for collections::get_size.
constexpr bool fixed
T is a value that is determinable at compile time.
Definition: fixed.hpp:66
constexpr auto get_size(Arg &&arg)
Get the size of a sized object (e.g, a collection)
Definition: get_size.hpp:188
constexpr std::size_t size_of_v
Helper for collections::size_of.
Definition: size_of.hpp:60