Boost logo

Boost Users :

Subject: [Boost-users] fusion::vector with 1 element, fusion::transform, boost::variant and boost::optional
From: Hicham Mouline (hicham_at_[hidden])
Date: 2010-09-08 23:49:19


Hello,
I have this error w msvc2008:

error C2664:
'nicohich::systems::make_parameters_for_simulate<parameters_t>::type::type(c
onst boost::fusion::vector1<T0> &)' : cannot convert parameter 1 from 'const
parameters_1_n_seq_t' to 'const boost::fusion::vector1<T0> &'
1> with
1> [
1> parameters_t=my_ns::systems::ns1::parameters,
1> T0=boost::variant<std::vector<double>,
my_ns::range_incr<double>, my_ns::range<double>,double>
1> ]
1> and
1> [
1> T0=boost::variant<std::vector<double>,
my_ns::range_incr<double>, my_ns::range<double>,double>
1> ]
1> Reason: cannot convert from 'const parameters_1_n_seq_t' to 'const
boost::fusion::vector1<T0>'
1> with
1> [
1> T0=boost::variant<std::vector<double>,
my_ns::range_incr<double>, my_ns::range<double>,double>
1> ]
1> No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called

where parameters_1_n_seq_t which is a result of a metafunction invocation
is: (as determined at runtime by typeid(parameters_1_n_seq_t).name(), I
manually edited out the namespaces and trailing boost templates args ):

fusion::transform_view<
  fusion::vector1<
    optional<
      variant<
        std::vector<double>,
        my_ns::range_incr<double>,
        my_ns::range<double>,
        double
>
>
>,
  deoptionalize_item,
  void_
>

where

struct deoptionalize_item
{
  typedef deoptionalize_item Self;

  template<typename Sign>
  struct result; // primary template

  template<typename T> // template spec
  struct result<Self( const boost::optional<T>& )>
  {
    typedef const T& type;
  };

  template <typename T>
  const T& operator()( const boost::optional<T>& rhs ) const
  {
    return *rhs;
  }
};

my_ns::systems::ns1::parameters is defined as:

namespace systems
{
struct base_parameters {
  double x;
};
namespace ns1
{
struct parameters : public base_parameters {
  // double y
};
}
}

// at global namespace
BOOST_FUSION_ADAPT_STRUCT(
  my_ns::systems::ns1::parameters,
  (double, x)
// (double, y)
)

Previously, parameters held the field y, and this error didn't happen.

Regards,


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net