OmniSciDB  2e3a973ef4
TypeHandler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, Inc.
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  * @description Sortable utility struct for visitor patterns.
19  */
20 
21 #pragma once
22 
23 #include <typeindex>
24 
25 template <typename T, typename U>
26 struct TypeHandler {
27  std::type_index type_index;
28  void (T::*handler)(U const*);
29 };
30 
31 template <typename T, typename U>
32 bool operator<(TypeHandler<T, U> const& lhs, TypeHandler<T, U> const& rhs) {
33  return lhs.type_index < rhs.type_index;
34 }
35 
36 template <typename T, typename U>
37 bool operator<(TypeHandler<T, U> const& lhs, std::type_index const& rhs) {
38  return lhs.type_index < rhs;
39 }
40 
41 template <typename T, typename U>
42 bool operator<(std::type_index const& lhs, TypeHandler<T, U> const& rhs) {
43  return lhs < rhs.type_index;
44 }
std::type_index type_index
Definition: TypeHandler.h:27
void(T::* handler)(U const *)
Definition: TypeHandler.h:28