Gazebo Physics

API Reference

7.6.0
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 gz
24 {
25  namespace physics
26  {
28  struct Empty { };
29 
32  template <class... T> struct type { };
33 
52  template <typename To, typename From>
54 
55  template <typename To, typename From>
56  struct ConstCompatible<To, const From>
57  : std::integral_constant<bool, std::is_const<To>::value> { };
58  }
59 }
60 
76 #define GZ_PHYSICS_CREATE_SELECTOR(X) \
77  template<typename InFeature> \
78  struct Select ## X \
79  { \
80  template<typename F, typename PolicyT, typename FeaturesT, \
81  typename = std::void_t<>> \
82  struct Implementation \
83  { \
84  using type = ::gz::physics::Empty; \
85  }; \
86  \
87  template<typename F, typename PolicyT, typename FeaturesT> \
88  struct Implementation<F, PolicyT, FeaturesT, \
89  std::void_t< \
90  typename F::template X <PolicyT, FeaturesT>>> \
91  { \
92  using type = typename F::template X <PolicyT, FeaturesT>; \
93  }; \
94  \
95  template <typename PolicyT, typename FeaturesT> \
96  using type = typename Implementation<InFeature, PolicyT, FeaturesT>::type; \
97  };
98 
99 #endif