28 #ifndef YSL_INC_CORE_YCUTIL_H_
29 #define YSL_INC_CORE_YCUTIL_H_ 1
42 template<
typename _type,
typename _tStrict,
typename _tWeak>
45 typedef typename std::conditional<std::is_convertible<_type,
63 template<
typename _type,
typename _tStrict>
84 template<
typename _type>
99 return a < b ? -1 : !(a == b);
106 template<
typename _type>
110 return a < b ? -1 : !(a == b);
134 template<
typename _type>
146 template<
typename _type>
150 YAssert(FetchZero<_type>() < b,
151 "Zero element as lower bound is not less than upper bound.");
153 return !(i < FetchZero<_type>()) && i < b;
160 template<
typename _type>
164 YAssert(a < b,
"Lower bound is not less than upper bound.");
166 return !(i < a) && i < b;
174 template<
typename _type>
178 YAssert(FetchZero<_type>() < b,
179 "Zero element as lower bound is not less than upper bound.");
181 return i > FetchZero<_type>() && i < b;
188 template<
typename _type>
193 "Lower bound is not less than upper bound.");
195 return i > a && i < b;
205 template<
typename _type>
209 YAssert(a,
"Null array pointer found."),
210 YAssert(n != 0,
"Zero length of array found.");
211 YAssert(!(v < *a),
"Value less than lower bound found.");
215 while(!(++i == n || v < a[i]))
228 template<
typename _type>
232 YAssert(a,
"Null array pointer found."),
233 YAssert(n != 0,
"Zero length of array found.");
234 YAssert(!(v < *a),
"Value less than lower bound found.");
239 while(!(++i == n || v < (s += a[i])))
250 template<
typename _type>
254 YAssert(!(b < a),
"Upper bound is less than lower bound.");
268 template<
typename _type>
272 YAssert(a < b,
"Lower bound is not less than upper bound.");
285 template<
typename _type>
299 template<
typename _type>
303 YAssert(b != FetchZero<_type>(),
"Zero upper bound found.");
314 template<
typename _type>
331 template<
typename _tOut>
335 typedef typename std::remove_reference<decltype(*dst)>::type _type;
337 static_assert(std::is_pod<_type>::value
338 || (std::is_nothrow_default_constructible<_type>::value
339 && std::is_nothrow_assignable<_type, _type>::value),
340 "Invalid type found.");
343 std::fill_n(dst, n, _type());
356 template<
typename _type>
375 template<
typename _type>
384 #ifdef YSL_USE_MEMORY_DEBUG
395 template<
typename _type>
414 template<
typename _type>
423 # define delete_obj delete_obj_debug
424 # define delete_second_mem delete_second_mem_debug
428 # define delete_obj delete_obj_ndebug
429 # define delete_second_mem delete_second_mem_ndebug
442 template<
typename _tPo
inter>
455 template<
typename _type>
459 return new typename std::remove_reference<decltype(*p)>::type(*p);
467 template<
class _type>
471 static_assert(std::is_polymorphic<
typename
472 std::remove_reference<decltype(*p)>::type>::value,
473 "Non-polymorphic class type found.");