StlFunctors.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_STL_FUNCTORS_H
11 #define EIGEN_STL_FUNCTORS_H
12 
13 // IWYU pragma: private
14 #include "../InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 namespace internal {
18 
19 // default functor traits for STL functors:
20 
21 template <typename T>
22 struct functor_traits<std::multiplies<T> > {
24 };
25 
26 template <typename T>
27 struct functor_traits<std::divides<T> > {
29 };
30 
31 template <typename T>
32 struct functor_traits<std::plus<T> > {
34 };
35 
36 template <typename T>
37 struct functor_traits<std::minus<T> > {
39 };
40 
41 template <typename T>
42 struct functor_traits<std::negate<T> > {
44 };
45 
46 template <typename T>
47 struct functor_traits<std::logical_or<T> > {
48  enum { Cost = 1, PacketAccess = false };
49 };
50 
51 template <typename T>
52 struct functor_traits<std::logical_and<T> > {
53  enum { Cost = 1, PacketAccess = false };
54 };
55 
56 template <typename T>
57 struct functor_traits<std::logical_not<T> > {
58  enum { Cost = 1, PacketAccess = false };
59 };
60 
61 template <typename T>
62 struct functor_traits<std::greater<T> > {
63  enum { Cost = 1, PacketAccess = false };
64 };
65 
66 template <typename T>
67 struct functor_traits<std::less<T> > {
68  enum { Cost = 1, PacketAccess = false };
69 };
70 
71 template <typename T>
72 struct functor_traits<std::greater_equal<T> > {
73  enum { Cost = 1, PacketAccess = false };
74 };
75 
76 template <typename T>
77 struct functor_traits<std::less_equal<T> > {
78  enum { Cost = 1, PacketAccess = false };
79 };
80 
81 template <typename T>
82 struct functor_traits<std::equal_to<T> > {
83  enum { Cost = 1, PacketAccess = false };
84 };
85 
86 template <typename T>
87 struct functor_traits<std::not_equal_to<T> > {
88  enum { Cost = 1, PacketAccess = false };
89 };
90 
91 #if (EIGEN_COMP_CXXVER < 17)
92 // std::unary_negate is deprecated since c++17 and will be removed in c++20
93 template <typename T>
94 struct functor_traits<std::unary_negate<T> > {
95  enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false };
96 };
97 
98 // std::binary_negate is deprecated since c++17 and will be removed in c++20
99 template <typename T>
100 struct functor_traits<std::binary_negate<T> > {
101  enum { Cost = 1 + functor_traits<T>::Cost, PacketAccess = false };
102 };
103 #endif
104 
105 #ifdef EIGEN_STDEXT_SUPPORT
106 
107 template <typename T0, typename T1>
108 struct functor_traits<std::project1st<T0, T1> > {
109  enum { Cost = 0, PacketAccess = false };
110 };
111 
112 template <typename T0, typename T1>
113 struct functor_traits<std::project2nd<T0, T1> > {
114  enum { Cost = 0, PacketAccess = false };
115 };
116 
117 template <typename T0, typename T1>
118 struct functor_traits<std::select2nd<std::pair<T0, T1> > > {
119  enum { Cost = 0, PacketAccess = false };
120 };
121 
122 template <typename T0, typename T1>
123 struct functor_traits<std::select1st<std::pair<T0, T1> > > {
124  enum { Cost = 0, PacketAccess = false };
125 };
126 
127 template <typename T0, typename T1>
128 struct functor_traits<std::unary_compose<T0, T1> > {
130 };
131 
132 template <typename T0, typename T1, typename T2>
133 struct functor_traits<std::binary_compose<T0, T1, T2> > {
135 };
136 
137 #endif // EIGEN_STDEXT_SUPPORT
138 
139 // allow to add new functors and specializations of functor_traits from outside Eigen.
140 // this macro is really needed because functor_traits must be specialized after it is declared but before it is used...
141 #ifdef EIGEN_FUNCTORS_PLUGIN
142 #include EIGEN_FUNCTORS_PLUGIN
143 #endif
144 
145 } // end namespace internal
146 
147 } // end namespace Eigen
148 
149 #endif // EIGEN_STL_FUNCTORS_H
T negate(const T &x)
Definition: packetmath_test_shared.h:26
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Definition: Eigen_Colamd.h:49
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: XprHelper.h:205
@ PacketAccess
Definition: XprHelper.h:206
@ Cost
Definition: XprHelper.h:206