From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Utilities/triple.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Runtime/Utilities/triple.h (limited to 'Runtime/Utilities/triple.h') diff --git a/Runtime/Utilities/triple.h b/Runtime/Utilities/triple.h new file mode 100644 index 0000000..4a3d5c1 --- /dev/null +++ b/Runtime/Utilities/triple.h @@ -0,0 +1,46 @@ +#pragma once + +// TEMPLATE STRUCT triple +template +struct triple +{ + // store a triple of values of the same type + + triple() + : first(T()), second(T()), third(T()) + { // construct from defaults + } + + triple(const T& _Val1, const T& _Val2, const T& _Val3) + : first(_Val1), second(_Val2), third(_Val3) + { // construct from specified values + } + + template + triple(const triple& _Right) + : first(_Right.first), second(_Right.second), third(_Right.third) + { // construct from a compatible triple + } + + T first; // the first stored value + T second; // the second stored value + T third; // the third stored value +}; + +template +inline bool operator==(const triple& _Left, const triple& _Right) +{ // test for triple equality + return (_Left.first == _Right.first && _Left.second == _Right.second && _Left.third == _Right.third); +} + +template +inline bool operator!=(const triple& _Left, const triple& _Right) +{ // test for triple inequality + return (!(_Left == _Right)); +} + +template +inline triple make_triple(T _Val1, T _Val2, T _Val3) +{ // return a triple composed from arguments + return (triple(_Val1, _Val2, _Val3)); +} \ No newline at end of file -- cgit v1.1-26-g67d0