farm-ng-core
utils.h
Go to the documentation of this file.
1 // Copyright (c) 2011, Hauke Strasdat
2 // Copyright (c) 2012, Steven Lovegrove
3 // Copyright (c) 2021, farm-ng, inc.
4 //
5 // Use of this source code is governed by an MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT.
8 
9 #pragma once
10 
11 #include <initializer_list>
12 #include <type_traits>
13 
14 namespace sophus {
15 namespace concepts {
16 
17 template <class TDerived, class TBase>
18 concept DerivedFrom = std::is_base_of_v<TBase, TDerived>;
19 
20 template <class TBase, class TDerived>
21 concept IsBaseOf = std::is_base_of_v<TBase, TDerived>;
22 
23 template <class TT, class TU>
24 concept SameAs = std::is_same_v<TT, TU>;
25 
26 template <class TT>
27 concept EnumType = std::is_enum_v<TT>;
28 
29 template <class TT>
30 concept Arithmetic = std::is_arithmetic_v<TT>;
31 
32 template <class TFrom, class TTo>
33 concept ConvertibleTo = std::is_convertible_v<TFrom, TTo> && requires {
34  static_cast<TTo>(std::declval<TFrom>());
35 };
36 
37 template <class TT, class... TArgs>
39  std::is_nothrow_destructible_v<TT> && std::is_constructible_v<TT, TArgs...>;
40 
41 template <class T>
42 concept Range = requires(T& t) {
43  t.begin();
44  t.end();
45 };
46 
47 } // namespace concepts
48 } // namespace sophus
sophus::concepts::SameAs
concept SameAs
Definition: utils.h:24
sophus::concepts::EnumType
concept EnumType
Definition: utils.h:27
sophus
Image MutImage, owning images types.
Definition: num_diff.h:20
sophus::concepts::Range
concept Range
Definition: utils.h:42
sophus::concepts::ConstructibleFrom
concept ConstructibleFrom
Definition: utils.h:38
sophus::concepts::DerivedFrom
concept DerivedFrom
Definition: utils.h:18
sophus::concepts::Arithmetic
concept Arithmetic
Definition: utils.h:30
sophus::concepts::IsBaseOf
concept IsBaseOf
Definition: utils.h:21
sophus::concepts::ConvertibleTo
concept ConvertibleTo
Definition: utils.h:33