stlab.adobe.com Adobe Systems Incorporated
identity_element.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 /*************************************************************************************************/
7 
8 #ifndef ADOBE_ALGORITHM_IDENTITY_ELEMENT_HPP
9 #define ADOBE_ALGORITHM_IDENTITY_ELEMENT_HPP
10 
11 #include <adobe/config.hpp>
12 
13 #include <algorithm>
14 #include <functional>
15 
16 /*************************************************************************************************/
17 
18 namespace adobe {
19 
20 /*************************************************************************************************/
27 template <typename Op>
29 {
31  typedef typename Op::result_type result_type;
32 
34  result_type operator()() const;
35 };
36 
42 template <typename T>
43 struct identity_element<std::plus<T> >
44 {
46  typedef T result_type;
47 
50  { return T(0); }
51 };
52 
58 template <typename T>
59 struct identity_element<std::multiplies<T> >
60 {
62  typedef T result_type;
63 
66  { return T(1); }
67 };
68 
69 /*************************************************************************************************/
70 
71 } // namespace adobe
72 
73 /*************************************************************************************************/
74 
75 #endif
76 
77 /*************************************************************************************************/
result_type operator()() const
Yields the identitiy element for addition.
STL namespace.
result_type operator()() const
Yields the identitiy element.
result_type operator()() const
Yields the identitiy element for multiplication.
T result_type
the type of the identity is the same as the result tyupe of the operation
Op::result_type result_type
the type of the identity is the same as the result tyupe of the operation
T result_type
the type of the identity is the same as the result tyupe of the operation

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google