Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-03-26 10:27:07


I'm trying to define any_pointer using dynamic_any library. Everything is
fine except lambda support. I can't compile this:

    any_int_pointer begin, end; // see example below for details
    std::for_each(begin, end, std::cout << x);

Lambda cannot deduce return type of *begin. What should I do? May be some
kind of traits or nested template should be defined for any?

-- 
Alexander Nasonov
Remove minus and all between minus and at from my e-mail for timely response
// any_pointer.cpp
typedef boost::dynamic_any::any<
    boost::mpl::list<
        boost::dynamic_any::dereference_to<int>,
        boost::dynamic_any::increment,
        boost::dynamic_any::not_equal_to
    >
> any_int_pointer;
int main()
{
    any_int_pointer begin, end;
    boost::lambda::placeholder1_type x;
    std::set<int> s;
    s.insert(2);
    s.insert(1);
    s.insert(0);
    begin = s.begin();
    end = s.end();    
    std::for_each(begin, end, std::cout << x);
    std::cout << "Enter integers and then EOF\n";
    
    begin = std::istream_iterator<int>(std::cin);
    end = std::istream_iterator<int>();
    std::for_each(begin, end, std::cout << x);
}

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk