| 1 | #// |
|---|
| 2 | #// Boost.Pointer Container |
|---|
| 3 | #// |
|---|
| 4 | #// Copyright Thorsten Ottosen 2003-2005. Use, modification and |
|---|
| 5 | #// distribution is subject to the Boost Software License, Version |
|---|
| 6 | #// 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 7 | #// http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 8 | #// |
|---|
| 9 | #// For more information, see http://www.boost.org/libs/ptr_container/ |
|---|
| 10 | #// |
|---|
| 11 | |
|---|
| 12 | 1. use splice() to speed up transfer for list |
|---|
| 13 | |
|---|
| 14 | 5. small usage exmaple with each class |
|---|
| 15 | |
|---|
| 16 | 10. update tutorial to show boost::assign link + auto_ptr |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | 11. should find_key() be added to ptr_map? |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | 13. transfer for set/map may need to |
|---|
| 24 | be revisted (rg. !from.empty() precondition) |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | 15. Some of the headlines are too big... |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | 18. range-based sort() needs to be provided for list. use stable_sort for this purpose. |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | 19. use flat_set,flat_map internally when certain situations arise, eg. when the size of the objects |
|---|
| 34 | is small, eg. 4bytes (does this affect key=string? |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | 21. map::at() should throw bad_index |
|---|
| 39 | |
|---|
| 40 | auto_type skal være converter-bar til std::auto_ptr<U>, if the deleter is |
|---|
| 41 | trivial (heap_clone_allocator) |
|---|
| 42 | |
|---|
| 43 | (Spørg Thomas Witt om denne ændring can komme med...kan ikke ødelægge existerende kode, som |
|---|
| 44 | vill have kaldt .release()) Kræve en hel del ambiguity resolution pga auto_ptr augument er |
|---|
| 45 | templates og ikke non-templates! Desuden kan vi ikke bruge non-template argument, da alle |
|---|
| 46 | converterings operatorer for auto_ptr tager en & argument og ikke en by-value!!! måske |
|---|
| 47 | skal der blot et hack til, hvor vi tilføjer en ny ukenkt klasse og overloader kun for |
|---|
| 48 | den, og så laver en implicit konvertering til denne i static_move_ptr |
|---|
| 49 | |
|---|
| 50 | The easiert implementation would be to detect its presence in the |
|---|
| 51 | body of the range based overloads and then dispatch to that implementation. |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | 22. hvor gode er kompilere til at optimere release() for en auto_ptr. Hvordan med move_ptr |
|---|
| 55 | and auto_ptr interaction? Contracts må kunne fortælle kompileren at den skal |
|---|
| 56 | genere optimeret kode |
|---|
| 57 | |
|---|
| 58 | template< class T > |
|---|
| 59 | class auto_ptr |
|---|
| 60 | { |
|---|
| 61 | T* get() const; |
|---|
| 62 | |
|---|
| 63 | // |
|---|
| 64 | // this expresses that the constructor is a no-op if |
|---|
| 65 | // the condition is true. This might be useful in many other |
|---|
| 66 | // context |
|---|
| 67 | // |
|---|
| 68 | ~auto_ptr() |
|---|
| 69 | precondition { if( get() == 0 ) return; } |
|---|
| 70 | |
|---|
| 71 | T* release() |
|---|
| 72 | postcondition { get() == 0; } |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | ... |
|---|
| 76 | |
|---|
| 77 | std::auto_ptr<T> p( new T ); |
|---|
| 78 | foo( p.release() ); |
|---|
| 79 | // don't generate destructor |
|---|
| 80 | |
|---|
| 81 | Does raw_storage iterator have an impact on in-place consrtcution |
|---|
| 82 | |
|---|
| 83 | |
|---|