#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm.hpp>
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/container/list/cons.hpp>
#include <boost/fusion/include/cons.hpp>
#include <boost/proto/proto.hpp>
template<typename T>
typename boost::proto::result_of::eval<T,boost::proto::default_context >::type
proto_force(T t){ return boost::proto::eval(t,boost::proto::default_context()); }
template<typename T>
typename
boost::proto::result_of::eval<
typename
T::cdr_type::car_type,
boost::proto::default_context >::type
stream_cdr(T t) { return proto_force((t.cdr).car);}
template<typename T1,typename T2>
typename
boost::fusion::cons<T1,
boost::fusion::cons<
typename
boost::proto::terminal<T2>::type
>>
stream_cons(T1 t1 ,T2 t2)
{
boost::proto::terminal<T2>::type td2={t2};
boost::fusion::cons<
boost::proto::terminal<T2>::type
> tc2(td2);
boost::fusion::cons<T1,
boost::fusion::cons<
boost::proto::terminal<T2>::type
>> tt(t1,tc2);
return tt;
}
int main()
{
auto s= stream_cons(2,stream_cons(1,0));
auto ss= stream_cons(3, s);
std::cout << proto_force(s.cdr.car).car << std::endl;
std::cout << proto_force(proto_force(s.cdr.car).cdr.car) << std::endl;
std::cout << s.car << std::endl;
std::cout << stream_cdr(s).car << std::endl;
std::cout << stream_cdr(ss).car << std::endl;
std::cout << proto_force(ss.cdr.car).car << std::endl;
std::cout << proto_force(
proto_force(ss.cdr.car).cdr.car).car << std::endl;
std::cout << stream_cdr(stream_cdr(ss)).car << std::endl;
}