提交 d419a9a4 编写于 作者: B Behdad Esfahbod

[iter] Use different SFINAE scheme to make MSVC happy

From Orvid King: TLDR; MSVC has some issues using sizeof(declval<T>()) for
SFINAE of templated types, so I just used SFINAE in a different context where
MSVC doesn't have the issue.
上级 2778df79
......@@ -202,15 +202,18 @@ struct hb_iter_with_fallback_t :
/* hb_is_iterable() */
template<typename T, typename B>
struct _hb_is_iterable
{ enum { value = false }; };
template<typename T>
struct _hb_is_iterable<T, hb_bool_tt<true || sizeof (hb_declval (T).iter ())> >
{ enum { value = true }; };
template<typename T>
struct hb_is_iterable { enum { value = _hb_is_iterable<T, hb_true_t>::value }; };
template <typename T>
struct hb_is_iterable
{
private:
template <typename U>
static auto test (int) -> decltype (hb_declval (U).iter (), hb_true_t ());
template <typename>
static hb_false_t test (...);
public:
enum { value = hb_is_same (decltype (test<T> (0)), hb_true_t) };
};
#define hb_is_iterable(Iterable) hb_is_iterable<Iterable>::value
/* TODO Add hb_is_iterable_of().
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册