5template < prototype_number NUMBER1, prototype_number NUMBER2 >
6void cast_copy(NUMBER1 & n1, NUMBER2 n2)
14template <
typename A,
typename B >
15inline void swap(A & a, B & b)
27template <
typename TYPE >
28constexpr memsize index_of(
const TYPE * p,
const TYPE * pBegin)
31 return ::is_set(p) ? (::memsize)(p - pBegin) : -1;
35template < prototype_
character CHARACTER >
36constexpr bool string_compare_prefix(::i32 & ordering,
const CHARACTER * pszA,
const CHARACTER * pszB)
noexcept
60 else if (::is_empty(pszB))
73template < prototype_
character CHARACTER >
74constexpr bool string_order_prefix(::std::strong_ordering & ordering,
const CHARACTER * pszA,
const CHARACTER * pszB)
noexcept
83 ordering = ::std::strong_ordering::equal;
91 ordering = ::std::strong_ordering::less;
98 else if (::is_empty(pszB))
101 ordering = ::std::strong_ordering::greater;
115template <
typename TYPE >
116void reverse(TYPE * begin, TYPE * end)
124 if (end <= begin)
return;
126 ::swap(*begin, *end);
134#include "acme/prototype/collection/pair.h"
152template < prototype_
signed SIGNED >
153constexpr auto as_absolute_unsigned(SIGNED i)
158 return ::make_pair{ (
typename std::make_unsigned<SIGNED>::type) ((bNegative = i < 0) ? -i : i), bNegative };
252inline const ::particle * context_trace_object() {
return general_trace_object(); }
257template <
typename PRED,
typename ... Args >
258inline bool _returns_true(PRED pred,
const true_type& predicate_returns_void,
bool bOnVoid, Args... args)
264template <
typename PRED,
typename ... Args >
265inline bool _returns_true(PRED pred,
const false_type& predicate_returns_void,
bool, Args... args)
267 return (
bool)pred(args...);
270template <
typename PRED,
typename ... Args >
271inline bool returns_true(PRED pred,
bool bOnVoid, Args... args)
274 return _returns_true(pred, is_void<
decltype(pred(args...))>, bOnVoid, args...);
278template <
typename PRED,
typename ... Args >
279inline bool _returns_false(PRED pred,
const true_type& predicate_returns_void,
bool bOnVoid, Args... args)
285template <
typename PRED,
typename ... Args >
286inline bool _returns_false(PRED pred,
const false_type& predicate_returns_void,
bool, Args... args)
288 return !(bool)pred(args...);
291template <
typename PRED,
typename ... Args >
292inline bool returns_false(PRED pred,
bool bOnVoid, Args... args)
295 return _returns_false(pred, is_void <
decltype(pred(args...)) >, bOnVoid, args...);
334template <
typename TYPE >
335inline bool is_reference_null(
const TYPE& t)
343template <
typename TYPE >
344inline bool is_reference_set(
const TYPE& t)
376inline void __dynamic_cast(T*& ptarget, T* psource)
384template <
class T ,
typename T2 >
385inline void __dynamic_cast(T * & ptarget, T2 * psource)
388 ptarget =
dynamic_cast < T *
>(psource);
393template <
typename T1,
typename T2 >
394inline bool __sort(T1& t1, T2& t2)
494template < prototype_
integral SECOND, prototype_
integral NANOSECOND >
495constexpr void normalize_second_nanosecond(SECOND &
second, NANOSECOND &
nanosecond)
508template < prototype_
integral SECOND1, prototype_
integral NANOSECOND1, prototype_
integral SECOND2, prototype_
integral NANOSECOND2 >
509constexpr void add_second_nanosecond(SECOND1 & second1, NANOSECOND1 & nanosecond1,
const SECOND2 & second2,
const NANOSECOND2 & nanosecond2)
512 auto nanos = nanosecond1 + nanosecond2;
514 auto extrasecond = nanos > 0 ? (nanos / 1'000'000'000) : ((nanos / 1'000'000'000) - 1);
516 second1 = second1 + second2 + extrasecond;
518 nanosecond1 = nanos - extrasecond * 1'000'000'000;
524template < prototype_
integral SECOND1, prototype_
integral NANOSECOND1, prototype_
integral SECOND2, prototype_
integral NANOSECOND2 >
525constexpr void subtract_second_nanosecond(SECOND1 & second1, NANOSECOND1 & nanosecond1,
const SECOND2 & second2,
const NANOSECOND2 & nanosecond2)
528 auto nanos = nanosecond1 - nanosecond2;
530 auto extrasecond = nanos > 0 ? (nanos / 1'000'000'000) : ((nanos / 1'000'000'000) - 1);
532 second1 = second1 - second2 + extrasecond;
534 nanosecond1 = nanos - extrasecond * 1'000'000'000;
539template <
typename TYPE >
540constexpr TYPE * find_first_null_character(TYPE * p)
557template <
typename TYPE, ::comparison::equality < TYPE > EQUALITY >
558constexpr const TYPE * find_first_null_character(
const TYPE * p, EQUALITY equality)
563 while (!equality.equals(*p, t))
575template < prototype_fundamental INTEGRAL >
576constexpr ::collection::count count_until_zero_item_type(
const INTEGRAL * p)
579 ::collection::count c = 0;
596template < prototype_
character CHARACTER >
597constexpr void null_terminate(
CHARACTER * & p)
605template < prototype_
character CHARACTER >
614template < prototype_iterator ITERATOR, prototype_iterator BEGIN >
615constexpr bool iterator_is_before_begin(ITERATOR p, BEGIN)
624template < prototype_iterator ITERATOR, prototype_iterator END >
625constexpr bool iterator_is_end(ITERATOR p, END pend)
628 return p.is_null() || p == pend;
633template < prototype_iterator ITERATOR, prototype_iterator BEGIN, prototype_iterator END >
634constexpr bool iterator_is_ok(ITERATOR p, BEGIN, END pend)
637 return p.is_ok() && p != pend;
642template <
typename TYPE,
typename BEGIN >
643constexpr bool iterator_is_before_begin(
const TYPE * p,
const BEGIN * begin)
651template <
typename TYPE,
typename END >
652constexpr bool iterator_is_end(
const TYPE * p,
const END * end)
660template <
typename TYPE,
typename BEGIN,
typename END >
661constexpr bool iterator_is_ok(
const TYPE * p,
const BEGIN * begin,
const END * end)
664 return p >= begin && p < end;
669template <
typename ITEM, ::comparison::equality < ITEM > EQUALITY >
670bool is_empty(
const ITEM * p, EQUALITY equality)
673 return ::is_null(p) || equality.equals(*p, 0);
678template <
typename ITEM, ::comparison::equality < ITEM > EQUALITY >
679constexpr bool _initialize_null_terminated_contains_null_terminated(
bool & b,
const ITEM * pz,
const ITEM * pzPrefix, EQUALITY equality)
682 if (::is_empty(pzPrefix, equality))
691 if (::is_empty(pz, equality))
706template <
typename ITEM, ::comparison::equality < ITEM > EQUALITY >
707constexpr bool _null_terminated_begins_null_terminated(
const ITEM * pz,
const ITEM * pzPrefix, EQUALITY equality)
713 if (!equality.equals(*pz, *pzPrefix))
724 }
while (!equality.equals(*pz,0) && !equality.equals(*pzPrefix, 0));
726 return equality.equals(*pzPrefix, 0);
731template <
typename ITEM, ::comparison::equality < ITEM > EQUALITY >
732constexpr bool null_terminated_begins_null_terminated(
const ITEM * pz,
const ITEM * pzPrefix, EQUALITY equality)
737 if (_initialize_null_terminated_contains_null_terminated(b, pz, pzPrefix, equality))
744 return _null_terminated_begins_null_terminated(pz, pzPrefix, equality);
749#include "acme/prototype/mathematics/_.h"
752template <
typename TYPE >
753TYPE * clipped_add(TYPE * p, ::collection::count c,
const non_const<TYPE> * begin,
const non_const<TYPE> * end)
759 p = minimum(p + c, end);
765 p = maximum(p + c, begin - 1);
777template < prototype_iterator ITERATOR,
typename T1,
typename T2 >
778ITERATOR clipped_add(ITERATOR p, ::collection::count c, T1, T2)
784 while (p.is_set() && c > 0)
798 while (p.is_set() && c < 0)
816template < prototype_
signed SIGNED >
825template <
typename T >
826bool found(
const T * p)
834template < prototype_
signed SIGNED >
835bool not_found(SIGNED s)
843template <
typename T >
844bool not_found(
const T * p)
856template <
typename BOOLEAN,
typename ASSIGNED,
typename ASSIGNEE >
857inline void set_if_different(BOOLEAN& bSetIfChanged, ASSIGNED& left,
const ASSIGNEE& right)
863 bSetIfChanged =
true;
873template < prototype_XYDim XYDim,
typename X,
typename Y,
typename W,
typename H >
874inline XYDim & set_dim(XYDim & rectTarget, X x, Y y, W w, H h)
877 cast_copy(rectTarget.X, x);
878 cast_copy(rectTarget.Y, y);
879 cast_copy(rectTarget.Width, w);
880 cast_copy(rectTarget.Height, h);
899template < prototype_rectangle RECTANGLE, prototype_xydim XYDIM >
900void copy(RECTANGLE & rectangle,
const XYDIM & xydim)
903 cast_copy(rectangle.left , xydim.x);
904 cast_copy(rectangle.top , xydim.y);
905 cast_copy(rectangle.right , xydim.x + xydim.width);
906 cast_copy(rectangle.bottom , xydim.y + xydim.height);
911template < prototype_origin_size ORIGIN_SIZE, prototype_rectangle RECTANGLE >
912void copy(ORIGIN_SIZE & originsize,
const RECTANGLE & rectangle)
915 cast_copy(originsize.origin.x , rectangle.left);
916 cast_copy(originsize.origin.y , rectangle.top);
917 cast_copy(originsize.size.width , rectangle.right - rectangle.left);
918 cast_copy(originsize.size.height , rectangle.bottom - rectangle.top);
923template < prototype_rectangle RECTANGLE1, prototype_origin_size RECTANGLE2 >
924void copy(RECTANGLE1 & rectangle1,
const RECTANGLE2 & rectangle2)
927 cast_copy(rectangle1.left , rectangle2.origin.x);
928 cast_copy(rectangle1.top , rectangle2.origin.y);
929 cast_copy(rectangle1.right , rectangle2.origin.x + rectangle2.size.width);
930 cast_copy(rectangle1.bottom , rectangle2.origin.y + rectangle2.size.height);
964template < prototype_XY POINT1, prototype_po
int POINT2 >
965void copy(POINT1 point1,
const POINT2 & point2)
968 cast_copy(point1.X, point2.x);
969 cast_copy(point1.Y, point2.y);
974template < prototype_po
int POINT1, prototype_XY POINT2 >
975void copy(POINT1 & point1,
const POINT2 & point2)
978 cast_copy(point1.x, point2.X);
979 cast_copy(point1.y, point2.Y);
984template < prototype_rectangle RECTANGLE1, prototype_rectangle RECTANGLE2 >
985void copy(RECTANGLE1 & rectangle1,
const RECTANGLE2 & rectangle2)
988 cast_copy(rectangle1.left, rectangle2.left);
989 cast_copy(rectangle1.top, rectangle2.top);
990 cast_copy(rectangle1.right, rectangle2.right);
991 cast_copy(rectangle1.bottom, rectangle2.bottom);
996template < prototype_XYDim XYDim, prototype_rectangle RECTANGLE >
997void copy(XYDim & xydim,
const RECTANGLE & rectangle)
1000 cast_copy(xydim.X, rectangle.left);
1001 cast_copy(xydim.Y, rectangle.top);
1002 cast_copy(xydim.Width, rectangle.right - rectangle.left);
1003 cast_copy(xydim.Height, rectangle.bottom - rectangle.top);
1008template < prototype_rectangle RECTANGLE, prototype_XYDim XYDim >
1009void copy(RECTANGLE & rectangle,
const XYDim & xydim)
1012 cast_copy(rectangle.left, xydim.X);
1013 cast_copy(rectangle.top, xydim.Y);
1014 cast_copy(rectangle.right, xydim.X + xydim.Width);
1015 cast_copy(rectangle.bottom, xydim.Y + xydim.Height);
1020template < prototype_xydim XYDIM, prototype_rectangle RECTANGLE >
1021void copy(XYDIM & xydim,
const RECTANGLE & rectangle)
1024 cast_copy(xydim.x, rectangle.left);
1025 cast_copy(xydim.y, rectangle.top);
1026 cast_copy(xydim.width, rectangle.right - rectangle.left);
1027 cast_copy(xydim.height, rectangle.bottom - rectangle.top);
1032template < prototype_XYDim XYDim1, prototype_XYDim XYDim2 >
1033void copy(XYDim1 & xydim1,
const XYDim2 & xydim2)
1036 cast_copy(xydim1.X, xydim2.X);
1037 cast_copy(xydim1.Y, xydim2.Y);
1038 cast_copy(xydim1.Width, xydim2.Width);
1039 cast_copy(xydim1.Height, xydim2.Height);
1044template < prototype_po
int POINT1, prototype_po
int POINT2 >
1045void copy(POINT1 & point1,
const POINT2 & point2)
1048 cast_copy(point1.x, point2.x);
1049 cast_copy(point1.y, point2.y);
1054template < prototype_po
int POINT1, raw_primitive_po
int POINT2 >
1055void copy(POINT1 & point1,
const POINT2 & point2)
1058 cast_copy(point1.x, point2.x);
1059 cast_copy(point1.y, point2.y);
1064template < raw_primitive_po
int POINT1, prototype_po
int POINT2 >
1065void copy(POINT1 & point1,
const POINT2 & point2)
1068 cast_copy(point1.x, point2.x);
1069 cast_copy(point1.y, point2.y);
1074template < prototype_po
int POINT, prototype_size SIZE >
1075void copy(POINT & point,
const SIZE & size)
1078 cast_copy(point.x, size.cx);
1079 cast_copy(point.y, size.cy);
1084template < prototype_size SIZE_TYPE1, prototype_size SIZE_TYPE2 >
1085void copy(SIZE_TYPE1 & size1,
const SIZE_TYPE2 & size2)
1088 cast_copy(size1.cx, size2.cx);
1089 cast_copy(size1.cy, size2.cy);
1094template <
typename CHAR_STRING >
1095inline bool is_string_empty(CHAR_STRING p) { return ::is_null(p) || *p ==
'\0'; }
Definition aaa_character.h:10
Definition aaa_nanosecond.h:9
Definition aaa_second.h:9