error C2664:
'discriminated_union<Seq_>::discriminated_union(const
discriminated_union<Seq_> &)' : cannot convert parameter 1 from 't1'
to 'const discriminated_union<Seq_>
&'
with
[
Seq_=types_vector
]
Reason: cannot convert from 't1'
to 'const
discriminated_union<Seq_>'
with
[
Seq_=types_vector
]
No user-defined-conversion
operator available that can perform this conversion, or the operator cannot be
called
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Ok, if I define the ctor param without typename const_ref<...>::type everything goes fine, if I use const_ref it fails. const_ref is defined as follows:
template<class
Ty>
struct const_ref
:
boost::add_reference
<
typename
boost::add_const
<
typename
boost::remove_reference<Ty>::type
>::type
>
{};
I can understand that the compiler is unable to make a decision which ctor to use, but I do not get an ambiguaty error. It seems like the compiler simply quits expanding templates and uses the last most successful ctor matched before the error. This happens only when I use mpl::vector templated type in conjunction with templated ctor. Other types like below work fine:
template<int D_,
class Ty_>
struct my_pair :
mpl::pair<mpl::int_<D_>,
Ty_>
{
typedef my_pair<D_,
Ty_> my_type;
inline my_pair()
{}
explicit inline my_pair( typename
const_ref<Ty_>::type ty)
:
second_(ty)
{}
explicit inline my_pair(const my_type&
other)
: second_(other.second_)
{}
inline my_type& operator =(const my_type&
other)
{
second_=other.second_;
return
*this;
}
second second_;
};
May be some of you have any suggestions.
Thanks a lot,
Ovanes Markarian