Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify code using BOOST::variant. #13570

Closed
wants to merge 1 commit into from
Closed

Conversation

bangerth
Copy link
Member

Following #13556, I looked up the Boost documentation at https://www.boost.org/doc/libs/1_78_0/doc/html/variant/reference.html#variant.concepts.static-visitor and realized that starting with C++14, one can omit writing a class on our own as a visitor, but that a generic lambda works as well. This patch does that, getting rid of a dozen lines or so.

/rebuild

@masterleinad
Copy link
Member

/Users/runner/work/dealii/dealii/bundled/boost-1.70.0/include/boost/variant/detail/apply_visitor_unary.hpp:98:33: error: no matching function for call to object of type '(lambda at /Users/runner/work/dealii/dealii/source/base/table_handler.cc:119:7)'
        typedef decltype(true ? boost::declval< Visitor& >()( boost::declval< value_t >() )
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/dealii/dealii/bundled/boost-1.70.0/include/boost/variant/detail/apply_visitor_unary.hpp:108:22: note: in instantiation of template class 'boost::detail::variant::result_multideduce1<(lambda at /Users/runner/work/dealii/dealii/source/base/table_handler.cc:119:7), boost::variant<int, unsigned int, unsigned long long, double, std::string>>::deduce_impl<boost::mpl::l_iter<boost::mpl::l_item<mpl_::long_<5>, int, boost::mpl::l_item<mpl_::long_<4>, unsigned int, boost::mpl::l_item<mpl_::long_<3>, unsigned long long, boost::mpl::l_item<mpl_::long_<2>, double, boost::mpl::l_item<mpl_::long_<1>, std::string, boost::mpl::l_end>>>>>>>' requested here
    typedef typename deduce_impl<begin_it>::type type;
                     ^
/Users/runner/work/dealii/dealii/bundled/boost-1.70.0/include/boost/variant/detail/apply_visitor_unary.hpp:114:22: note: in instantiation of template class 'boost::detail::variant::result_multideduce1<(lambda at /Users/runner/work/dealii/dealii/source/base/table_handler.cc:119:7), boost::variant<int, unsigned int, unsigned long long, double, std::string>>' requested here
    typedef typename result_multideduce1<Visitor, Variant>::type result_type;
                     ^
/Users/runner/work/dealii/dealii/bundled/boost-1.70.0/include/boost/variant/detail/apply_visitor_unary.hpp:135:98: note: in instantiation of template class 'boost::detail::variant::result_wrapper1<(lambda at /Users/runner/work/dealii/dealii/source/base/table_handler.cc:119:7), boost::variant<int, unsigned int, unsigned long long, double, std::string>>' requested here
    boost::detail::variant::result_wrapper1<Visitor, typename remove_reference<Visitable>::type> cpp14_vis(::boost::forward<Visitor>(visitor));
                                                                                                 ^
/Users/runner/work/dealii/dealii/source/base/table_handler.cc:118:12: note: in instantiation of function template specialization 'boost::apply_visitor<(lambda at /Users/runner/work/dealii/dealii/source/base/table_handler.cc:119:7), boost::variant<int, unsigned int, unsigned long long, double, std::string> &>' requested here
    boost::apply_visitor(
           ^
/Users/runner/work/dealii/dealii/source/base/table_handler.cc:119:7: note: candidate function [with arg:auto = int] not viable: expects an lvalue for 1st argument
      [](auto &arg) { arg = std::remove_reference_t<decltype(arg)>(); },
      ^
1 error generated.

@bangerth
Copy link
Member Author

Ah, that's a shame. It compiles on my system, but let's not worry about it then. The code will disappear anyway once we use C++17.

@bangerth bangerth closed this Mar 24, 2022
@bangerth bangerth deleted the variant branch March 24, 2022 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants