-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstl_function.h
More file actions
55 lines (43 loc) · 1.71 KB
/
Copy pathstl_function.h
File metadata and controls
55 lines (43 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// Created by sakura on 2020/5/22.
//
#ifndef SAKURA_STL_STL_FUNCTION_H
#define SAKURA_STL_STL_FUNCTION_H
#include "stl_config.h"
__STL_BEGIN_NAMESPACE
template<class _Arg, class _Result>
struct unary_function {
typedef _Arg argument_type; ///< @c argument_type is the type of the
/// argument (no surprises here)
typedef _Result result_type; ///< @c result_type is the return type
};
template<class _Arg1, class _Arg2, class _Result>
struct binary_function {
typedef _Arg1 first_argument_type; ///< the type of the first argument
/// (no surprises here)
typedef _Arg2 second_argument_type; ///< the type of the second argument
typedef _Result result_type; ///< type of the return type
};
template<class _Tp>
struct equal_to : public binary_function<_Tp, _Tp, bool> {
bool operator()(const _Tp &__x, const _Tp &__y) const { return __x == __y; }
};
// select1st and select2nd are extensions: they are not part of the standard.
template<class _Pair>
struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> {
const typename _Pair::first_type &operator()(const _Pair &__x) const {
return __x.first;
}
};
template<class _Pair>
struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> {
const typename _Pair::second_type &operator()(const _Pair &__x) const {
return __x.second;
}
};
template<class _Tp>
struct _Identity : public unary_function<_Tp, _Tp> {
const _Tp &operator()(const _Tp &__x) const { return __x; }
};
__STL_END_NAMESPACE
#endif //SAKURA_STL_STL_FUNCTION_H