Gazebo Physics

API Reference

5.3.2
gz/physics/TemplateHelpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_PHYSICS_TEMPLATEHELPERS_HH_
19 #define GZ_PHYSICS_TEMPLATEHELPERS_HH_
20 
21 #include <type_traits>
22 
23 namespace ignition
24 {
25  namespace physics
26  {
28  struct Empty { };
29 
32  template <class... T> struct type { };
33 
36  template <typename...>
37  using void_t = void;
38 
57  template <typename To, typename From>
59 
60  template <typename To, typename From>
63  }
64 }
65 
81 #define IGN_PHYSICS_CREATE_SELECTOR(X) \
82  template<typename InFeature> \
83  struct Select ## X \
84  { \
85  template<typename F, typename PolicyT, typename FeaturesT, \
86  typename = ::ignition::physics::void_t<>> \
87  struct Implementation \
88  { \
89  using type = ::ignition::physics::Empty; \
90  }; \
91  \
92  template<typename F, typename PolicyT, typename FeaturesT> \
93  struct Implementation<F, PolicyT, FeaturesT, \
94  ::ignition::physics::void_t< \
95  typename F::template X <PolicyT, FeaturesT>>> \
96  { \
97  using type = typename F::template X <PolicyT, FeaturesT>; \
98  }; \
99  \
100  template <typename PolicyT, typename FeaturesT> \
101  using type = typename Implementation<InFeature, PolicyT, FeaturesT>::type; \
102  };
103 
104 #endif
Contains a static constexpr field named value which will be true if the type From has a const-quality...
Definition: gz/physics/TemplateHelpers.hh:58
This can be used to turn a type into a function argument, which is useful for template metaprogrammin...
Definition: gz/physics/TemplateHelpers.hh:32
Useful as a blank placeholder in template metaprogramming.
Definition: gz/physics/TemplateHelpers.hh:28
void void_t
Definition: gz/physics/TemplateHelpers.hh:37
Definition: gz/physics/TemplateHelpers.hh:61