[Boost-bugs] [Boost C++ Libraries] #6971: apply_visitor doesn't work with rvalue / const variants

Subject: [Boost-bugs] [Boost C++ Libraries] #6971: apply_visitor doesn't work with rvalue / const variants
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-06-07 19:42:20


#6971: apply_visitor doesn't work with rvalue / const variants
------------------------------------+---------------------------------------
 Reporter: adam.ciganek@… | Owner: ebf
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: variant
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
------------------------------------+---------------------------------------
 Hello,

 I noticed the `apply_visitor` function doesn't work when the passed in
 variant is const or rvalue. This is because there is no overload accepting
 the variant via const reference. Is this deliberate, or is it an omission?

 In case this is an omission, the fix seems to be trivial. The
 `apply_visitor` function seems to simply forward to the internal
 `apply_visitor` member function of the variant type. There is already a
 const version of this member function in the boost::variant sources, so
 all that is needed is to add new free `apply_visitor` function that takes
 the variant parameter by const reference and call it's `apply_visitor`
 member. Something like this:

 {{{
 template<typename Visitor, typename Visitable>
 inline typename Visitor::result_type apply_visitor(Visitor& visitor, const
 Visitable& visitable)
 {
   return visitable.apply_visitor(visitor);
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6971>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC