Boost logo

Boost Users :

From: AJD (n.outpost_at_[hidden])
Date: 2007-12-08 13:23:48


"Eric Niebler" <eric_at_[hidden]> wrote in message
news:<475A0ED4.1010307_at_[hidden]>...
> template< typename T, typename U = proto::is_proto_expr >
> struct vector2;
>
> template< typename T >
> struct vector2<T[3]>
> {
> BOOST_PROTO_EXTENDS(typename proto::terminal<T[3]>::type,
> vector2<T[3]>, VectorDomain)
>
> typedef T value_type;
>
> T & operator [](std::size_t i)
> {
> return proto::arg(*this)[i];
> }
>
> T const & operator [](std::size_t i) const
> {
> return proto::arg(*this)[i];
> }
> };
>
> // Tell proto that in the VectorDomain, all
> // expressions should be wrapped in vector_expr<>
> struct VectorDomain
> : proto::domain<
> proto::pod_generator< vector_expr >
> , VectorGrammar
> >
> {
> };

Thanks, this works great. The only problem is that vector<> is intended as a
wrapper class, and I just implemented it as an array for convenience in this
example. It could have any underlying type, not necessarily an array. Is
there a proper way to do this without exposing vector<>'s underlying type?


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