libTriton version 1.0 build 1590
Loading...
Searching...
No Matches
comparableFunctor.hpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#ifndef TRITON_COMPARABLE_FUNCTOR_H
9#define TRITON_COMPARABLE_FUNCTOR_H
10
11#include <functional>
12#include <utility>
13
14
15
17namespace triton {
28 template <class Signature>
30 private:
32 std::function<Signature> F_;
33
35 void* ID_;
36
37 public:
39 ComparableFunctor(std::function<Signature> F, void* ID)
40 : F_(std::move(F)), ID_(ID) {
41 }
42
44 ComparableFunctor(Signature* F)
45 : F_(F), ID_((void*)F) {
46 }
47
49 template <class apiType>
50 auto operator()(apiType& api) const -> decltype(F_(api)) {
51 return F_(api);
52 }
53
55 template <class apiType, class paramType>
56 auto operator()(apiType& api, paramType& param) const -> decltype(F_(api, param)) {
57 return F_(api, param);
58 }
59
61 template <class apiType, class paramType1, class paramType2>
62 auto operator()(apiType& api, paramType1& param1, paramType2& param2) const -> decltype(F_(api, param1, param2)) {
63 /* We don't use C++ variadic templates to support VS2013... */
64 return F_(api, param1, param2);
65 }
66
68 template <class T>
69 bool operator==(const ComparableFunctor<T>& O) const {
70 return this->ID_ == O.ID_;
71 }
72
74 template <class T>
75 bool operator!=(const ComparableFunctor<T>& O) const {
76 return !(this->ID_ == O.ID_);
77 }
78 };
80}
81
82#endif
The Triton namespace.
auto operator()(apiType &api, paramType1 &param1, paramType2 &param2) const -> decltype(F_(api, param1, param2))
Forward call to real functor.
auto operator()(apiType &api, paramType &param) const -> decltype(F_(api, param))
Forward call to real functor.
bool operator==(const ComparableFunctor< T > &O) const
Comparison of functor based on id.
ComparableFunctor(std::function< Signature > F, void *ID)
Constructor.
bool operator!=(const ComparableFunctor< T > &O) const
Comparison of functor based on id.
auto operator()(apiType &api) const -> decltype(F_(api))
Forward call to real functor.
ComparableFunctor(Signature *F)
Constructor.