Gazebo Physics

API Reference

8.0.0~pre2
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
23namespace gz
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 GZ_PHYSICS_CREATE_SELECTOR(X) \
82 template<typename InFeature> \
83 struct Select ## X \
84 { \
85 template<typename F, typename PolicyT, typename FeaturesT, \
86 typename = ::gz::physics::void_t<>> \
87 struct Implementation \
88 { \
89 using type = ::gz::physics::Empty; \
90 }; \
91 \
92 template<typename F, typename PolicyT, typename FeaturesT> \
93 struct Implementation<F, PolicyT, FeaturesT, \
94 ::gz::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