clDNN
meta_utils.hpp
1 /*
2 // Copyright (c) 2017 Intel Corporation
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 #pragma once
17 
18 #include <type_traits>
19 
20 namespace cldnn
21 {
22 
23 struct primitive;
24 
25 namespace meta
26 {
27 
28 //helper struct to tell wheter type T is any of given types U...
29 //termination case when U... is empty -> return std::false_type
30 template <class T, class... U>
31 struct is_any_of : public std::false_type {};
32 
33 //helper struct to tell whether type is any of given types (U, Rest...)
34 //recurrence case when at least one type U is present -> returns std::true_type if std::same<T, U>::value is true, otherwise call is_any_of<T, Rest...> recurrently
35 template <class T, class U, class... Rest>
36 struct is_any_of<T, U, Rest...> : public std::conditional<std::is_same<T, U>::value, std::true_type, is_any_of<T, Rest...>>::type {};
37 
38 template <class T>
39 struct always_false : public std::false_type {};
40 
41 template <typename Ty, Ty Val>
42 struct always_false_ty_val : public std::false_type {};
43 
44 template <typename Ty, Ty ... Vals>
45 struct val_tuple {};
46 
47 template <bool... Values>
48 struct all : public std::true_type {};
49 
50 template <bool Val, bool... Values>
51 struct all<Val, Values...> : public std::integral_constant<bool, Val && all<Values...>::value> {};
52 
53 }
54 }