Yes you can, std::tie
returns a std::tuple<T&...>
where T...
are the types that are given to it.
std::ignore
has an unspecified type, but it will still appear in the tuple
according to where you specified it in std::tie
.
If if makes you feel better, you could include in your code somewhere:
int n;
auto i = std::tie(std::ignore, n);
auto j = std::tie(n, std::ignore);
auto k = std::tie(n);
static_assert(!std::is_same<decltype(i), decltype(j)>::value, "");
static_assert(!std::is_same<decltype(i), decltype(k)>::value, "");
static_assert(!std::is_same<decltype(j), decltype(k)>::value, "");
and so on for whatever combinations you are explicitly using. This way compilation will fail if your assumption is invalid.