| 1 | // ptr_list.hpp |
| 2 | // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/) |
| 3 | // |
| 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_SPIRIT_SUPPORT_DETAIL_LEXER_CONTAINERS_PTR_LIST_HPP |
| 7 | #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_CONTAINERS_PTR_LIST_HPP |
| 8 | |
| 9 | #include <list> |
| 10 | |
| 11 | namespace boost |
| 12 | { |
| 13 | namespace lexer |
| 14 | { |
| 15 | namespace detail |
| 16 | { |
| 17 | template<typename Type> |
| 18 | class ptr_list |
| 19 | { |
| 20 | public: |
| 21 | typedef std::list<Type *> list; |
| 22 | |
| 23 | ptr_list () |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | ~ptr_list () |
| 28 | { |
| 29 | clear (); |
| 30 | } |
| 31 | |
| 32 | list *operator -> () |
| 33 | { |
| 34 | return &_list; |
| 35 | } |
| 36 | |
| 37 | const list *operator -> () const |
| 38 | { |
| 39 | return &_list; |
| 40 | } |
| 41 | |
| 42 | list &operator * () |
| 43 | { |
| 44 | return _list; |
| 45 | } |
| 46 | |
| 47 | const list &operator * () const |
| 48 | { |
| 49 | return _list; |
| 50 | } |
| 51 | |
| 52 | void clear () |
| 53 | { |
| 54 | while (!_list.empty ()) |
| 55 | { |
| 56 | delete _list.front (); |
| 57 | _list.pop_front (); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | private: |
| 62 | list _list; |
| 63 | |
| 64 | ptr_list (const ptr_list &); // No copy construction. |
| 65 | ptr_list &operator = (const ptr_list &); // No assignment. |
| 66 | }; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | #endif |
| 72 | |