https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61368
--- Comment #1 from Piotr Bartosiewicz <p.bartosiewi at partner dot samsung.com> --- template <typename C> static true_type test(decltype(std::declval<C>().template visit(std::declval<VisitorMatcher>()))*); This fixes the problem, but still don't know whether gcc or clang is wrong about the original code.