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 <type_traits>
25 
27 {
31 #ifdef __cpp_concepts
32  template<sized T>
33 #else
34  template<typename T, typename = void>
35 #endif
36  struct size_of : std::integral_constant<std::size_t, dynamic_size> {};
37 
38 
39 #ifdef __cpp_concepts
40  template<sized T> requires values::fixed<decltype(get_size(std::declval<T>()))>
41  struct size_of<T>
42 #else
43  template<typename T>
44  struct size_of<T, std::enable_if_t<values::fixed<decltype(get_size(std::declval<T>()))>>>
45 #endif
46  : std::integral_constant<std::size_t, values::fixed_number_of_v<decltype(get_size(std::declval<T>()))>> {};
47 
48 
52 #ifdef __cpp_concepts
53  template<sized T>
54 #else
55  template<typename T>
56 #endif
57  inline constexpr std::size_t size_of_v = size_of<T>::value;
58 
59 
60 } // namespace OpenKalman::collections
61 
62 #endif //OPENKALMAN_COLLECTIONS_SIZE_OF_HPP
Namespace for collections.
Definition: collections.hpp:27
Definition for values::fixed_number_of.
The size of a sized object (including a collection).
Definition: size_of.hpp:36
Definition for collections::sized.
Definition for collections::get_size.
Definition for ::fixed.
constexpr bool fixed
T is a values::value that is determinable at compile time.
Definition: fixed.hpp:60
Global definitions for OpenKalman.
constexpr auto get_size(Arg &&arg)
Get the size of a sized object (e.g, a collection)
Definition: get_size.hpp:191
constexpr std::size_t size_of_v
Helper for collections::size_of.
Definition: size_of.hpp:57