Add utility functions for rdctype::pair, make_pair and cast to tuple

* make_pair is obvious, the cast to tuple allows using std::tie to split
  a returned pair into two local variables.
This commit is contained in:
baldurk
2017-04-07 10:54:21 +01:00
parent 4c0fc8ce1d
commit 05d0e2eb77
+12
View File
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
// we provide a basic templated type that is a fixed array that just contains a pointer to the
@@ -46,8 +47,19 @@ struct pair
{
A first;
B second;
operator std::tuple<A &, B &>() { return std::tie(first, second); }
};
template <typename A, typename B>
pair<A, B> make_pair(const A &a, const B &b)
{
pair<A, B> ret;
ret.first = a;
ret.second = b;
return ret;
}
template <typename T>
struct array
{