Example #1
0
static bool
TestTie()
{
  int i;
  float f;
  char c;
  Tuple<int, float, char> rhs1(42, 0.5f, 'c');
  Tie(i, f, c) = rhs1;
  CHECK(i == Get<0>(rhs1));
  CHECK(f == Get<1>(rhs1));
  CHECK(c == Get<2>(rhs1));
  // Test conversions
  Tuple<ConvertibleToInt, double, unsigned char> rhs2(ConvertibleToInt(),
      0.7f, 'd');
  Tie(i, f, c) = rhs2;
  CHECK(i == Get<0>(rhs2));
  CHECK(f == Get<1>(rhs2));
  CHECK(c == Get<2>(rhs2));

  // Test Pair
  Pair<int, float> rhs3(-1, 1.2f);
  Tie(i, f) = rhs3;
  CHECK(i == rhs3.first());
  CHECK(f == rhs3.second());

  pair<int, float> rhs4(42, 1.5f);
  Tie(i, f) = rhs4;
  CHECK(i == rhs4.first);
  CHECK(f == rhs4.second);

  return true;
}