Skip to content

Commit 2b001d9

Browse files
committed
fix: older gcc SFINAE bug
1 parent d3d8f79 commit 2b001d9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

include/boost/buffers/data_source.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ struct is_data_source
4040
};
4141

4242
template<class T>
43-
struct is_data_source<T, detail::void_t<typename
44-
std::enable_if<
43+
struct is_data_source<T, detail::void_t<
44+
decltype(std::declval<T const&>().data())>>
45+
: std::integral_constant<bool,
4546
std::is_nothrow_move_constructible<T>::value &&
4647
buffers::is_const_buffer_sequence<
47-
decltype(std::declval<T const&>().data())>::value
48-
>::type> >
49-
: std::true_type
48+
decltype(std::declval<T const&>().data())>::value>
5049
{
5150
};
5251

test/unit/data_source.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,26 @@ struct read_source
5555
system::error_code&);
5656
};
5757

58+
// blows up in gcc 5,6,7 without workarounds
59+
struct gcc_banger
60+
{
61+
template<class T,
62+
typename std::enable_if<
63+
is_data_source<typename std::decay<T>::type>::value,
64+
int>::type = 0>
65+
gcc_banger(T&&);
66+
67+
gcc_banger(gcc_banger&&) = default;
68+
};
69+
5870
} // (anon)
5971

6072
BOOST_CORE_STATIC_ASSERT( is_data_source<test_source>::value);
6173
BOOST_CORE_STATIC_ASSERT(! is_data_source<int>::value);
6274
BOOST_CORE_STATIC_ASSERT(! is_data_source<not_source1>::value);
6375
BOOST_CORE_STATIC_ASSERT(! is_data_source<not_source2>::value);
6476
BOOST_CORE_STATIC_ASSERT(! is_data_source<read_source>::value);
77+
BOOST_CORE_STATIC_ASSERT(! is_data_source<gcc_banger>::value);
6578

6679
struct data_source_test
6780
{

0 commit comments

Comments
 (0)