27 #include <boost/container/vector.hpp>
28 #include <boost/array.hpp>
45 template<
typename T>T
VectorGetOrDefault(
const boost::container::vector<T> &v,
int index,
char* file,
char* func,
int line) {
49 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Vector index: %d < 0) at File: %s / Func: %s / Line: %d\n", index, file, func, line);
50 OutputDebugString(debugstr);
52 }
else if (index > static_cast<int>(v.size() - 1)) {
53 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Vector index: %d > %d) at File: %s / Func: %s / Line: %d\n", index, static_cast<int>(v.size() - 1), file, func, line);
54 OutputDebugString(debugstr);
60 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (This Vector is Empty) at File: %s / Func: %s / Line: %d\n", file, func, line);
61 OutputDebugString(debugstr);
62 return static_cast<T
>(0.0);
76 template<
typename T, std::
size_t N>T
ArrayGetOrDefault(
const boost::array<T, N>&a,
int index,
char* file,
char* func,
int line) {
80 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Array index: %d < 0) at File: %s / Func: %s / Line: %d\n", index, file, func, line);
81 OutputDebugString(debugstr);
83 }
else if (index > static_cast<int>(a.size() - 1)) {
84 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Array index: %d > %d) at File: %s / Func: %s / Line: %d\n", index, static_cast<int>(a.size() - 1), file, func, line);
85 OutputDebugString(debugstr);
91 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (This Array is Empty) at File: %s / Func: %s / Line: %d\n", file, func, line);
92 OutputDebugString(debugstr);
93 return static_cast<T
>(0.0);
98 T
VectorTryGet(
const boost::container::vector<T> &v,
int index,
char* file,
char* func,
int line) {
101 }
catch (std::out_of_range) {
105 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Vector index: %d < 0) at File: %s / Func: %s / Line: %d\n", index, file, func, line);
106 OutputDebugString(debugstr);
107 }
else if (index > static_cast<int>(v.size() - 1)) {
108 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Vector index: %d > %d) at File: %s / Func: %s / Line: %d\n", index, static_cast<int>(v.size() - 1), file, func, line);
109 OutputDebugString(debugstr);
112 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (This Vector is Empty) at File: %s / Func: %s / Line: %d\n", file, func, line);
113 OutputDebugString(debugstr);
119 template<
typename T, std::
size_t N>
120 T
ArrayTryGet(
const boost::array<T, N> &a,
int index,
char* file,
char* func,
int line) {
123 }
catch (std::out_of_range) {
127 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Array index: %d < 0) at File: %s / Func: %s / Line: %d\n", index, file, func, line);
128 OutputDebugString(debugstr);
129 }
else if (index > static_cast<int>(a.size() - 1)) {
130 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (Array index: %d > %d) at File: %s / Func: %s / Line: %d\n", index, static_cast<int>(a.size() - 1), file, func, line);
131 OutputDebugString(debugstr);
134 sprintf_s(debugstr,
sizeof(debugstr),
"Out of Renge!!! (This Array is Empty) at File: %s / Func: %s / Line: %d\n", file, func, line);
135 OutputDebugString(debugstr);
T VectorTryGet(const boost::container::vector< T > &v, int index, char *file, char *func, int line)
Definition: Base.h:98
テンプレートを記述する基底クラス
Definition: Base.h:33
T VectorGetOrDefault(const boost::container::vector< T > &v, int index, char *file, char *func, int line)
vectorコンテナへの範囲外アクセス時にデフォルト値を返す関数
Definition: Base.h:45
T ArrayTryGet(const boost::array< T, N > &a, int index, char *file, char *func, int line)
Definition: Base.h:120
T ArrayGetOrDefault(const boost::array< T, N > &a, int index, char *file, char *func, int line)
arrayコンテナへの範囲外アクセス時にデフォルト値を返す関数
Definition: Base.h:76