Boost logo

Boost Users :

From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2008-08-20 03:24:23


> [ignore this line: it makes gmane stop complaining about top-posting]

Hi!

Trying to migrate existing code from boost::xxx to std::tr1::xxx using
the boost::tr1 implementation for Visual Studio 2005 SP1
In the presence of some exotic autoconversion utility the
the std::tr1::tuple version of my code fails on vc8.
The error messages indicate that the conversion operator
is not considered by the compiler.

Below is code that fails to compile on vc8 if USE_TR1 is defined
Do you have an idea how to fix this?

Thanx, Markus

---snip---
#include <boost/tr1/memory.hpp>

#ifdef USE_TR1
  #include <boost/tr1/tuple.hpp>
#else
  #include <boost/tuple/tuple.hpp>
#endif

#include <boost/any.hpp>

#include <iostream>

namespace Core
{

class AutoConverter
{
        std::tr1::shared_ptr<boost::any> t_;

public:
        AutoConverter(std::tr1::shared_ptr<boost::any> const & t)
                : t_(t)
        {}
        
        template <typename C>
        operator C ()
        {
                try
                {
                        boost::any & a = (*t_);
                        
                        return boost::any_cast<C>(a);
                }
                catch(boost::bad_any_cast & e)
                {
                        std::cerr << "Internal conversion bug: "
                                          << "Failed to convert data holder
to "
                                          << typeid(C).name() << "\n"
                                          << e.what()
                                          << std::endl;
                        
                        C c = C();
                        return c;
                }
        }
};

inline AutoConverter Demo()
{
#ifdef USE_TR1
        std::tr1::shared_ptr<boost::any> p_result
                (new boost::any(std::tr1::make_tuple(1, 2, 3, 4)));
#else
        std::tr1::shared_ptr<boost::any> p_result
                (new boost::any(boost::make_tuple(1, 2, 3, 4)));
#endif

        return p_result;
}

} // namespace Core

int main(int argc, char* argv[])
{
#ifdef USE_TR1
        std::tr1::tuple<int, int, int, int> test = Core::Demo();
#else
        boost::tuple<int, int, int, int> test = Core::Demo();
#endif
        return 0;
}
---snip---

Error message is:

>------ Build started: Project: TR1TupleConversionProblem, Configuration:
 Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>TR1TupleConversionProblem.cpp
1>[...]\boost_1_36_0\boost\fusion\sequence\intrinsic\begin.hpp(56) :
error C2504: 'boost::fusion::extension::begin_impl<Tag>::apply<Sequence>' :
 base class undefined
1> with
1> [
1> Tag=boost::fusion::non_fusion_tag
1> ]
1> and
1> [
1> Sequence=const Core::AutoConverter
1> ]
1> [...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp
(65) : see reference to class template instantiation
'boost::fusion::result_of::begin<Sequence>' being compiled
1> with
1> [
1> Sequence=const Core::AutoConverter
1> ]
1> [...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp
(105) : see reference to function template instantiation
'boost::fusion::vector_data4<Derived,T0,T1,T2,T3>
boost::fusion::vector_data4<Derived,T0,T1,T2,T3>::
init_from_sequence<Sequence>(const Sequence &)' being compiled
1> with
1> [
1> Derived=boost::fusion::vector4<int,int,int,int>,
1> T0=int,
1> T1=int,
1> T2=int,
1> T3=int,
1> Sequence=Core::AutoConverter
1> ]
1> [...]\boost_1_36_0\boost\fusion\container\vector\vector.hpp(58) :
see reference to function template instantiation
'boost::fusion::vector4<T0,T1,T2,T3>::vector4<T>(const Sequence &)'
being compiled
1> with
1> [
1> T0=int,
1> T1=int,
1> T2=int,
1> T3=int,
1> T=Core::AutoConverter,
1> Sequence=Core::AutoConverter
1> ]
1> [...]\boost_1_36_0\boost\fusion\tuple\tuple.hpp(33) :
see reference to function template instantiation
'boost::fusion::vector<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>::
vector<Sequence>(const Sequence &)' being compiled
1> with
1> [
1> T0=int,
1> T1=int,
1> T2=int,
1> T3=int,
1> T4=boost::fusion::void_,
1> T5=boost::fusion::void_,
1> T6=boost::fusion::void_,
1> T7=boost::fusion::void_,
1> T8=boost::fusion::void_,
1> T9=boost::fusion::void_,
1> Sequence=Core::AutoConverter
1> ]
1> [MYPATH]\tr1tupleconversionproblem.cpp(69) :
see reference to function template instantiation
'boost::fusion::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>::
tuple<Core::AutoConverter>(const Sequence &)' being compiled
1> with
1> [
1> T0=int,
1> T1=int,
1> T2=int,
1> T3=int,
1> T4=boost::fusion::void_,
1> T5=boost::fusion::void_,
1> T6=boost::fusion::void_,
1> T7=boost::fusion::void_,
1> T8=boost::fusion::void_,
1> T9=boost::fusion::void_,
1> Sequence=Core::AutoConverter
1> ]
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(65) :
error C2039: 'type' : is not a member of
'boost::fusion::result_of::begin<Sequence>'
1> with
1> [
1> Sequence=const Core::AutoConverter
1> ]
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(65) :
 error C2146: syntax error : missing ';' before identifier 'I0'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(65) :
 error C4430: missing type specifier - int assumed.
Note: C++ does not support default-int
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(65) :
 error C2065: 'I0' : undeclared identifier
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(66) :
 error C2146: syntax error : missing ';' before identifier 'i0'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(66) :
 error C2065: 'i0' : undeclared identifier
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(66) :
 error C2893: Failed to specialize function template
'const result_of::begin<const Sequence>::type
boost::fusion::begin(const Sequence &)'
1> With the following template arguments:
1> 'Core::AutoConverter'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(66) :
error C2893: Failed to specialize function template
'const result_of::begin<Sequence>::type boost::fusion::begin(Sequence &)'
1> With the following template arguments:
1> 'const Core::AutoConverter'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(67) :
error C2955: 'boost::fusion::result_of::next' :
use of class template requires template argument list
1> [...]\boost_1_36_0\boost\fusion\iterator\next.hpp(50) :
see declaration of 'boost::fusion::result_of::next'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(67) :
error C2039: 'type' : is not a member of 'boost::fusion::result_of::next'
1> [...]\boost_1_36_0\boost\fusion\iterator\next.hpp(50) :
see declaration of 'boost::fusion::result_of::next'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(67) :
error C2039: 'type' :
is not a member of 'boost::fusion::result_of::next<Iterator>'
1> with
1> [
1> Iterator=I1
1> ]
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(67) :
error C2893: Failed to specialize function template
'const result_of::next<Iterator>::type boost::fusion::next(const Iterator &)'
1> With the following template arguments:
1> 'I1'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(67) :
error C2039: 'type' : is not a member of
'boost::fusion::result_of::next<Iterator>'
1> with
1> [
1> Iterator=I1
1> ]
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(67) :
error C2893: Failed to specialize function template
'const result_of::next<Iterator>::type boost::fusion::next(const Iterator &)'
1> With the following template arguments:
1> 'I2'
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(68) :
error C2100: illegal indirection
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(68) :
error C2100: illegal indirection
1>[...]\boost_1_36_0\boost\fusion\container\vector\detail\vector_n.hpp(68) :
error C2100: illegal indirection


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