Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
identity_element.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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
18namespace adobe {
19
20/**************************************************************************************************/
27template <typename Op>
30 typedef typename Op::result_type result_type;
31
34};
35
41template <typename T>
42struct identity_element<std::plus<T>> {
44 typedef T result_type;
45
47 result_type operator()() const { return T(0); }
48};
49
55template <typename T>
56struct identity_element<std::multiplies<T>> {
58 typedef T result_type;
59
61 result_type operator()() const { return T(1); }
62};
63
64/**************************************************************************************************/
65
66} // namespace adobe
67
68/**************************************************************************************************/
69
70#endif
71
72/**************************************************************************************************/
STL namespace.
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
result_type operator()() const
Yields the identitiy element for addition.
T result_type
the type of the identity is the same as the result tyupe of the operation
result_type operator()() const
Yields the identitiy element.
Op::result_type result_type
the type of the identity is the same as the result tyupe of the operation