Commit 06cfaf7d authored by Dominik Charousset's avatar Dominik Charousset

Fix conversion constructor for caf::span

parent 4c2c9871
...@@ -695,8 +695,8 @@ template <class T, class To> ...@@ -695,8 +695,8 @@ template <class T, class To>
class has_convertible_data_member { class has_convertible_data_member {
private: private:
template <class U> template <class U>
static auto sfinae(U* x) static auto sfinae(U* x) -> std::integral_constant<
-> decltype(std::declval<To*>() = x->data(), std::true_type()); bool, std::is_convertible<decltype(x->data()), To*>::value>;
template <class U> template <class U>
static auto sfinae(...) -> std::false_type; static auto sfinae(...) -> std::false_type;
......
...@@ -114,4 +114,10 @@ CAF_TEST(make_span) { ...@@ -114,4 +114,10 @@ CAF_TEST(make_span) {
CAF_CHECK_EQUAL(begin(ys), begin(zs)); CAF_CHECK_EQUAL(begin(ys), begin(zs));
} }
CAF_TEST(spans are convertible from compatible containers) {
std::vector<int> xs{1, 2, 3};
span<const int> ys{xs};
CAF_CHECK(std::equal(xs.begin(), xs.end(), ys.begin()));
}
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment