This problem actually surfaced with gcc 6 when trying to create a copy of std::experimental::optional<json11::Json>, but I believe these two lines simulate the underlying issue even with earlier gcc versions:
error: 'const class std::experimental::fundamentals_v1::optional<json11::Json>' has no member named 'begin'
Json(const V & v) : Json(array(v.begin(), v.end())) {}
I think the correct error would be that there is no matching operator=. The enable_if condition for vector-like objects is too loose, because optionals also have a member type value_type.
A quickfix (checking for presence of a begin() function) seems to solve the issue.
This problem actually surfaced with gcc 6 when trying to create a copy of
std::experimental::optional<json11::Json>
, but I believe these two lines simulate the underlying issue even with earlier gcc versions:The compilation fails with:
I think the correct error would be that there is no matching
operator=
. Theenable_if
condition for vector-like objects is too loose, because optionals also have a member typevalue_type
.A quickfix (checking for presence of a
begin()
function) seems to solve the issue.