1 // Copyright (c) 2017-2021 Antony Polukhin
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #include "boost/config.hpp"
8 #include "boost/variant.hpp"
9 
10 struct foo {};
11 
12 struct some_user_provided_visitor_for_lvalues: boost::static_visitor<void> {
operator ()some_user_provided_visitor_for_lvalues13     void operator()(foo& ) const {}
operator ()some_user_provided_visitor_for_lvalues14     void operator()(int ) const {}
15 };
16 
main()17 int main() {
18     boost::apply_visitor(
19         some_user_provided_visitor_for_lvalues(),
20         boost::variant<int, foo>(foo())
21     );
22 
23 #ifdef __GNUC__
24 #   if __GNUC__ < 5 && __GNUC_MINOR__ < 8
25 #       error This test does not pass on GCC < 4.8 because of the incomplete C++11 support
26 #   endif
27 #endif
28 
29 #ifdef BOOST_MSVC
30 #   error Temporaries/rvalues could bind to non-const lvalues on MSVC compilers
31 #endif
32 }
33