14 #ifndef ALPS_PARAMS_SERIALIZE_VARIANT_HPP_d116b6a1742b418f851e0dbb87004644    15 #define ALPS_PARAMS_SERIALIZE_VARIANT_HPP_d116b6a1742b418f851e0dbb87004644    17 #include <boost/variant.hpp>    18 #include <boost/mpl/for_each.hpp>    20 #include <boost/optional.hpp>    26         template <
typename MPLSEQ, 
typename CONSUMER, 
typename PRODUCER>
    27         class variant_serializer {
    29             typedef typename boost::make_variant_over<MPLSEQ>::type variant_type;
    30             typedef CONSUMER consumer_type;
    31             typedef PRODUCER producer_type;
    35             struct consume_visitor : 
public boost::static_visitor<> {
    36                 consumer_type& consumer_;
    38                 consume_visitor(consumer_type& consumer) : consumer_(consumer) {}
    41                 void operator()(
const T& val)
 const    49                 producer_type& producer_;
    52                 maker(producer_type& producer, variant_type& var)
    53                     : producer_(producer), var_(var)
    58                 void operator()(
const T&) {
    59                     boost::optional<T> maybe_val=producer_((T*)0);
    60                     if (maybe_val) var_=*maybe_val;
    67             static void consume(consumer_type& consumer, 
const variant_type& var)
    73             static variant_type produce(producer_type& producer)
    76                 boost::mpl::for_each<MPLSEQ>(maker(producer, var));
 F::result_type apply_visitor(F &visitor, dictionary::const_iterator it)
Const-access visitor to a value by an iterator.