id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 11251,boost::static_visitor causes a compilation error in C++14 mode,bogdan ,Antony Polukhin,"Consider the following code: {{{#!cpp #include #include ""boost/variant.hpp"" struct test_vis : boost::static_visitor { int& operator()(int& i) const { return i; } }; int main() { boost::variant dummy; ++boost::apply_visitor(test_vis(), dummy); std::cout << dummy << '\n'; } }}} Clang 3.6.0 compiles the code with no diagnostics in C++11 mode, but in C++14 mode it issues the following error: {{{ prog.cc:12:6: error: call to 'apply_visitor' is ambiguous ++boost::apply_visitor(test_vis(), dummy); ^~~~~~~~~~~~~~~~~~~~ /boost/variant/detail/apply_visitor_unary.hpp:82:1: note: candidate function [with Visitor = test_vis, Visitable = boost::variant] apply_visitor(const Visitor& visitor, Visitable& visitable) ^ /boost/variant/detail/apply_visitor_unary.hpp:160:23: note: candidate function [with Visitor = test_vis, Visitable = boost::variant] inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable& visitable, ^ 1 error generated. }}} The same behaviour occurs in GCC 5.1.0. MSVC12 compiles the code, MSVC14 issues a similar error. This is due to the fact that the `apply_visitor` overloads using automatic return type detection are not disabled in this case, because the `boost::detail::variant::has_result_type` trait is not working properly for reference types. Internally, it uses an overload with a parameter type of `typename C::result_type*`, which tries to form a pointer to reference type in this case, which causes a deduction failure. A quick workaround is to remove the base class for the visitor in C++14 mode in this case.",Bugs,closed,Boost 1.59.0,variant,Boost 1.58.0,Regression,fixed,variant visitor reference return,