2 // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_LEXER_PTR_VECTOR_HPP
7 #define BOOST_LEXER_PTR_VECTOR_HPP
9 #include "../size_t.hpp"
18 template<typename Type>
22 typedef std::vector<Type *> vector;
33 vector *operator -> ()
38 const vector *operator -> () const
48 const vector &operator * () const
53 Type * &operator [] (const std::size_t index_)
55 return _vector[index_];
58 Type * const &operator [] (const std::size_t index_) const
60 return _vector[index_];
63 bool operator == (const ptr_vector &rhs_) const
65 bool equal_ = _vector.size () == rhs_._vector.size ();
69 typename vector::const_iterator lhs_iter_ = _vector.begin ();
70 typename vector::const_iterator end_ = _vector.end ();
71 typename vector::const_iterator rhs_iter_ = rhs_._vector.begin ();
73 for (; equal_ && lhs_iter_ != end_; ++lhs_iter_, ++rhs_iter_)
75 equal_ = **lhs_iter_ == **rhs_iter_;
84 if (!_vector.empty ())
86 Type **iter_ = &_vector.front ();
87 Type **end_ = iter_ + _vector.size ();
89 for (; iter_ != end_; ++iter_)
101 ptr_vector (const ptr_vector &); // No copy construction.
102 ptr_vector &operator = (const ptr_vector &); // No assignment.
In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move.
Douglas Adams