variant_visit_internal_linkage.cpp 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //-----------------------------------------------------------------------------
  2. // boost-libs variant/test/variant_visit_internal_linkage.cpp header file
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. //-----------------------------------------------------------------------------
  5. //
  6. // Copyright (c) 2018 Louis Dionne, Antony Polukhin
  7. //
  8. // Distributed under the Boost Software License, Version 1.0. (See
  9. // accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. // This test checks that we can visit a variant containing a type that has
  12. // internal linkage (anonymous namespace).
  13. #include "boost/variant/variant.hpp"
  14. #ifdef BOOST_NO_CXX14_DECLTYPE_AUTO
  15. void run() {}
  16. #else
  17. namespace {
  18. struct Foo { };
  19. struct Visitor {
  20. void operator()(Foo const&) const { }
  21. };
  22. }
  23. void run() {
  24. boost::variant<Foo> v = Foo();
  25. boost::apply_visitor(Visitor(), v);
  26. }
  27. #endif
  28. int main() {
  29. run();
  30. }