Gennadiy Rozental:
> > > template<typename T>
> > > void foo( T const& )
> > > {
> > >  ....
> > > }
> > >
> > > int main()
> > > {
> > >     boost::variant<int,.....> v = 5;
> > >
> > >    // Here I want to pass const reference to integer value of variant
to
> > > function foo
> > >   // foo( get<int>( v ) ); - type T is incorrect
> > >    foo( ??? );
> > > }
> >
> > I don't see why this wouldn't work. What is "incorrect" regarding type
T?
>
> Try to compile and run this:
> #include <iostream>
>
> template<typename T>
> void
> foo( T const& )
> {
>    std::cout << typeid(T).name() << std::endl;
> }
>
> template<typename T>
> struct get {
>     operator T&() { return m_t; }
>
>     T m_t;
> };
>
>
> int main()
> {
>    foo( get<int>() );
> }

Sorry, I now understand. While I had planned to abandon this approach due to
MSVC conformance problems, I see now it must be abandoned for a more
significant reason.

Thanks,
Eric



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to