NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
ne_stl_value_def.h
浏览该文件的文档.
1#ifndef NE_STL_INCLUDENE_STL_VALUE_DEF_H
2#define NE_STL_INCLUDENE_STL_VALUE_DEF_H
3
4#include "ne_stl_build.h"
6
7namespace nstd {
8
9struct _container_npos : integral_constant<std::size_t, (std::size_t)(-1)> {};
11
14
15enum class stateful_bool : int32_t { kBegin = -1, kUnused = kBegin, kFalse = 0, kTrue = 1, kEnd };
16template <stateful_bool _value>
21
22#define NIM_STD_DBL_MAX (1.7976931348623156e+200) // max value
23#define NIM_STD_DBL_MIN (2.2250738585072014e-200) // min positive value
24#define NIM_STD_DBL_DEFAULT (1.7976931348623155e+200) // def value
25#define NIM_STD_DBL_EPSILON (2.2204460492503131e-16) // epsilon
26
28 inline static double epsilon_value() { return NIM_STD_DBL_EPSILON; }
29 inline static double max_value() { return NIM_STD_DBL_MAX; }
30 inline static double nim_value() { return NIM_STD_DBL_MIN; }
31 inline static double default_value() { return NIM_STD_DBL_DEFAULT; }
32 inline static bool is_equal(double valuea, double valueb) { return (fabs(valuea - valueb) <= epsilon_value()); }
33 inline static bool is_default_value(double value) { return (is_equal(default_value(), value)); }
34};
35template <class first_type, class second_type>
36struct pair {
38 : first()
39 , second() {}
40
41 template <class _first_type = first_type, class _second_type = second_type>
42 pair(const _first_type& val1, const _second_type& val2)
43 : first(val1)
44 , second(val2) {}
45
46 pair(const pair&) = default;
47
48 template <class _self = pair>
49 pair& operator=(const _self& right) {
50 first = right.first;
51 second = right.second;
52 return *this;
53 }
54
55 void swap(pair& right) {
56 if (this != std::addressof(right)) {
57 swap(first, right.first);
58 swap(second, right.second);
59 }
60 }
61 first_type first; // the first stored value
62 second_type second; // the second stored value
63};
64template <class first_type, class second_type>
65pair<first_type, second_type> make_pair(const first_type& _first, const second_type& _second) {
66 return pair<first_type, second_type>(_first, _second);
67}
68} // namespace nstd
69
70#endif // !NE_STL_INCLUDENE_STL_VALUE_DEF_H
Definition ne_stl_any.h:7
pair< first_type, second_type > make_pair(const first_type &_first, const second_type &_second)
Definition ne_stl_value_def.h:65
stateful_bool
Definition ne_stl_value_def.h:15
#define NIM_STD_DBL_MIN
Definition ne_stl_value_def.h:23
#define NIM_STD_DBL_MAX
Definition ne_stl_value_def.h:22
#define NIM_STD_DBL_DEFAULT
Definition ne_stl_value_def.h:24
#define NIM_STD_DBL_EPSILON
Definition ne_stl_value_def.h:25
Definition ne_stl_value_def.h:12
Definition ne_stl_value_def.h:9
Definition ne_stl_type_traits.h:9
Definition ne_stl_value_def.h:27
static double max_value()
Definition ne_stl_value_def.h:29
static bool is_equal(double valuea, double valueb)
Definition ne_stl_value_def.h:32
static bool is_default_value(double value)
Definition ne_stl_value_def.h:33
static double nim_value()
Definition ne_stl_value_def.h:30
static double default_value()
Definition ne_stl_value_def.h:31
static double epsilon_value()
Definition ne_stl_value_def.h:28
Definition ne_stl_value_def.h:36
pair & operator=(const _self &right)
Definition ne_stl_value_def.h:49
pair(const _first_type &val1, const _second_type &val2)
Definition ne_stl_value_def.h:42
second_type second
Definition ne_stl_value_def.h:62
pair()
Definition ne_stl_value_def.h:37
first_type first
Definition ne_stl_value_def.h:61
pair(const pair &)=default
void swap(pair &right)
Definition ne_stl_value_def.h:55