Consider this code:
std::vector<
std::tuple,
std::vector,
std::vector>
> foo = {
{{2, 1, 2, 3}, {1, 2}, {2, 3}},
{{2, 3, 4, 0}, {3}, {2, 3, 4}},
{{2, 3, 4, 0}, {0}, {3, 4, 0}},
};
In Clang, and GCC 6 or later it compiles fine. In GCC 5.5 it gives this error:
In function 'int main()':
:16:4: error: converting to
'std::tuple >,
std::vector >,
std::vector > >'
from initializer list would use explicit constructor
'constexpr std::tuple< >::tuple(const _Elements& ...)
[with _Elements = {
std::vector >, std::vector >, std::vector >}]'
};
^
Why is this and how can I work around it?
Answer
One possible workaround is to call tuple
constructor explicitly:
using bar = std::tuple,
std::vector,
std::vector>;
std::vector foo = {
bar{{2, 1, 2, 3}, {1, 2}, {2, 3}},
bar{{2, 3, 4, 0}, {3}, {2, 3, 4}},
bar{{2, 3, 4, 0}, {0}, {3, 4, 0}},
};
No comments:
Post a Comment