diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Utilities/triple.h |
Diffstat (limited to 'Runtime/Utilities/triple.h')
-rw-r--r-- | Runtime/Utilities/triple.h | 46 |
1 files changed, 46 insertions, 0 deletions
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<class T> +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<class otherT> + triple(const triple<otherT>& _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<class T> +inline bool operator==(const triple<T>& _Left, const triple<T>& _Right) +{ // test for triple equality + return (_Left.first == _Right.first && _Left.second == _Right.second && _Left.third == _Right.third); +} + +template<class T> +inline bool operator!=(const triple<T>& _Left, const triple<T>& _Right) +{ // test for triple inequality + return (!(_Left == _Right)); +} + +template<class T> +inline triple<T> make_triple(T _Val1, T _Val2, T _Val3) +{ // return a triple composed from arguments + return (triple<T>(_Val1, _Val2, _Val3)); +}
\ No newline at end of file |