[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-users
Subject:    [Boost-users] [variant] apply_visitor to rvalue variant
From:       Marc Mutz <marc () klaralvdalens-datakonsult ! se>
Date:       2006-07-10 9:19:54
Message-ID: 200607101119.55677.marc () klaralvdalens-datakonsult ! se
[Download RAW message or body]

Hi,

My gcc 4.0 doesn't let me call apply_visitor on an rvalue variant. This is due 
to the Variant argument being a non-const reference, I guess. Is this a 
deliberate design decision (if so, the rationale should be documented), an 
oversight (in that case, it should be fixed), or a compiler bug (highly 
unlikely, since all of gcc 3.2 through 4.1 would then have it).

Testcase (== usecase) attached.

Thanks,
Marc

-- 
Marc Mutz -- marc@klaralvdalens-datakonsult.se, mutz@kde.org
Klarälvdalens Datakonsult AB, Platform-independent software solutions

["test_variant_rvalue_visitation.cpp" (text/x-c++src)]

#include <boost/variant.hpp>
#include <boost/lexical_cast.hpp>

#include <string>

typedef boost::variant<int, double, std::string> Variant;

Variant foo();

struct ToString : boost::static_visitor<std::string> {
    template <typename T>
    std::string operator()( const T & t ) const {
        return boost::lexical_cast<std::string>( t );
    }
};

int main() {
    const std::string str = apply_visitor( ToString(), foo() );
}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic