From boost-users Mon Jul 10 09:19:54 2006 From: Marc Mutz Date: Mon, 10 Jul 2006 09:19:54 +0000 To: boost-users Subject: [Boost-users] [variant] apply_visitor to rvalue variant Message-Id: <200607101119.55677.marc () klaralvdalens-datakonsult ! se> X-MARC-Message: https://marc.info/?l=boost-users&m=118835460023240 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_7uhsEbJSnweafDE" --Boundary-00=_7uhsEbJSnweafDE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, My gcc 4.0 doesn't let me call apply_visitor on an rvalue variant. This is = due=20 to the Variant argument being a non-const reference, I guess. Is this a=20 deliberate design decision (if so, the rationale should be documented), an= =20 oversight (in that case, it should be fixed), or a compiler bug (highly=20 unlikely, since all of gcc 3.2 through 4.1 would then have it). Testcase (=3D=3D usecase) attached. Thanks, Marc =2D-=20 Marc Mutz -- marc@klaralvdalens-datakonsult.se, mutz@kde.org Klar=E4lvdalens Datakonsult AB, Platform-independent software solutions --Boundary-00=_7uhsEbJSnweafDE Content-Type: text/x-c++src; charset="iso-8859-1"; name="test_variant_rvalue_visitation.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test_variant_rvalue_visitation.cpp" #include #include #include typedef boost::variant Variant; Variant foo(); struct ToString : boost::static_visitor { template std::string operator()( const T & t ) const { return boost::lexical_cast( t ); } }; int main() { const std::string str = apply_visitor( ToString(), foo() ); } --Boundary-00=_7uhsEbJSnweafDE--