Changeset 54660


Ignore:
Timestamp:
Jul 5, 2009, 12:15:52 AM (9 years ago)
Author:
cschladetsch
Message:

udpated docs

Location:
sandbox/cloneable/libs/cloneable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sandbox/cloneable/libs/cloneable/doc/cloneable.qbk

    r54658 r54660  
    588588``
    589589
    590 More details are in the `clonable::traits<T>` structure. [@boost:/libs/cloneable/boost/cloneable/traits.hpp traits.hpp]
    591 
    592 [endsect]
    593 
     590Full details are in [@boost:/boost/cloneable/traits.hpp traits.hpp].
     591
     592[endsect]
    594593
    595594[endsect]
     
    884883        typedef heterogenous::map<Animal> Map;
    885884        Map map;
    886         Map::value_type pair0 = map.key<Dog>("spot", 12).value<Dog>("rover", 8).value;
    887         Map::value_type pair1 = map.key<Cat>("sam", 6).value<Cat>("sooty", 10).value;
    888         Map::value_type pair2 = map.key<Cat>("fluffy", 10).value<Cat>("tigger", 14).value;
    889         Map::value_type pair3 = map.key<Labrador>("max", 12).value<Cat>("sooty", 3).value;
    890        
     885        map.key<Dog>("spot", 12).value<Dog>("rover", 8);
     886        map.key<Cat>("sam", 6).value<Cat>("sooty", 10);
     887        map.key<Cat>("fluffy", 10).value<Cat>("tigger", 14);
     888        map.key<Labrador>("max", 12).value<Cat>("sooty", 3);
     889       
     890        // make a deep copy of both the keys and values in the map
    891891        Map copy = map;
    892892       
    893         Map::iterator found_pair0 = map.find<Cat>("sam", 6);
    894        
    895         assert(&found_pair0->first == pair1.first);
     893        // can search for any type of animal
     894        assert(copy.find<Animal>("spot", 12) != copy.end());
     895        assert(copy.find<Animal>("sam", 6) != copy.end());
     896       
     897        // or, search for specific animal instances
     898        assert(copy.find<Dog>("spot", 12) != copy.end());
     899        assert(copy.find<Cat>("spot", 12) == copy.end());
     900        assert(copy.find<Cat>("sam", 6) != copy.end());
     901        assert(copy.find<Dog>("max", 12) != copy.end());
     902        assert(copy.find<Dog>("fluffy", 10) == copy.end());
    896903       
    897904        return 0;
  • sandbox/cloneable/libs/cloneable/doc/html/cloneable/change_log.html

    r54658 r54660  
    2828</h2></div></div></div>
    2929<a name="cloneable.change_log.version_0_1"></a><h4>
    30 <a name="id687458"></a>
     30<a name="id684182"></a>
    3131      <a class="link" href="change_log.html#cloneable.change_log.version_0_1">Version 0.1</a>
    3232    </h4>
  • sandbox/cloneable/libs/cloneable/doc/html/cloneable/heterogenous_containers/map.html

    r54657 r54660  
    3737        <span class="keyword">typedef</span> <span class="identifier">heterogenous</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">Animal</span><span class="special">&gt;</span> <span class="identifier">Map</span><span class="special">;</span>
    3838        <span class="identifier">Map</span> <span class="identifier">map</span><span class="special">;</span>
    39         <span class="identifier">Map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">pair0</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"spot"</span><span class="special">,</span> <span class="number">12</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"rover"</span><span class="special">,</span> <span class="number">8</span><span class="special">).</span><span class="identifier">value</span><span class="special">;</span>
    40         <span class="identifier">Map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">pair1</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sam"</span><span class="special">,</span> <span class="number">6</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sooty"</span><span class="special">,</span> <span class="number">10</span><span class="special">).</span><span class="identifier">value</span><span class="special">;</span>
    41         <span class="identifier">Map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">pair2</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"fluffy"</span><span class="special">,</span> <span class="number">10</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"tigger"</span><span class="special">,</span> <span class="number">14</span><span class="special">).</span><span class="identifier">value</span><span class="special">;</span>
    42         <span class="identifier">Map</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">pair3</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Labrador</span><span class="special">&gt;(</span><span class="string">"max"</span><span class="special">,</span> <span class="number">12</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sooty"</span><span class="special">,</span> <span class="number">3</span><span class="special">).</span><span class="identifier">value</span><span class="special">;</span>
     39        <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"spot"</span><span class="special">,</span> <span class="number">12</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"rover"</span><span class="special">,</span> <span class="number">8</span><span class="special">);</span>
     40        <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sam"</span><span class="special">,</span> <span class="number">6</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sooty"</span><span class="special">,</span> <span class="number">10</span><span class="special">);</span>
     41        <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"fluffy"</span><span class="special">,</span> <span class="number">10</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"tigger"</span><span class="special">,</span> <span class="number">14</span><span class="special">);</span>
     42        <span class="identifier">map</span><span class="special">.</span><span class="identifier">key</span><span class="special">&lt;</span><span class="identifier">Labrador</span><span class="special">&gt;(</span><span class="string">"max"</span><span class="special">,</span> <span class="number">12</span><span class="special">).</span><span class="identifier">value</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sooty"</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span>
    4343       
    44         <span class="identifier">Map</span> <span class="identifier">copy</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">;</span>
     44        <span class="comment">// make a deep copy of both the keys and values in the map
     45</span> <span class="identifier">Map</span> <span class="identifier">copy</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">;</span>
    4546       
    46         <span class="identifier">Map</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">found_pair0</span> <span class="special">=</span> <span class="identifier">map</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sam"</span><span class="special">,</span> <span class="number">6</span><span class="special">);</span>
     47        <span class="comment">// can search for any type of animal
     48</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Animal</span><span class="special">&gt;(</span><span class="string">"spot"</span><span class="special">,</span> <span class="number">12</span><span class="special">)</span> <span class="special">!=</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
     49        <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Animal</span><span class="special">&gt;(</span><span class="string">"sam"</span><span class="special">,</span> <span class="number">6</span><span class="special">)</span> <span class="special">!=</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
    4750       
    48         <span class="identifier">assert</span><span class="special">(&amp;</span><span class="identifier">found_pair0</span><span class="special">-&gt;</span><span class="identifier">first</span> <span class="special">==</span> <span class="identifier">pair1</span><span class="special">.</span><span class="identifier">first</span><span class="special">);</span>
     51        <span class="comment">// or, search for specific animal instances
     52</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"spot"</span><span class="special">,</span> <span class="number">12</span><span class="special">)</span> <span class="special">!=</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
     53        <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"spot"</span><span class="special">,</span> <span class="number">12</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
     54        <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Cat</span><span class="special">&gt;(</span><span class="string">"sam"</span><span class="special">,</span> <span class="number">6</span><span class="special">)</span> <span class="special">!=</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
     55        <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"max"</span><span class="special">,</span> <span class="number">12</span><span class="special">)</span> <span class="special">!=</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
     56        <span class="identifier">assert</span><span class="special">(</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">find</span><span class="special">&lt;</span><span class="identifier">Dog</span><span class="special">&gt;(</span><span class="string">"fluffy"</span><span class="special">,</span> <span class="number">10</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">copy</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
    4957       
    5058        <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
  • sandbox/cloneable/libs/cloneable/doc/html/cloneable/tutorial/cloneable_traits.html

    r54659 r54660  
    5454      </p>
    5555<p>
    56         Full details are in <a href="../../../../../../boost/cloneable/traits.hpp" target="_top">traits.hpp</a>
     56        Full details are in <a href="../../../../../../boost/cloneable/traits.hpp" target="_top">traits.hpp</a>.
    5757      </p>
    5858</div>
  • sandbox/cloneable/libs/cloneable/doc/html/index.html

    r54658 r54660  
    2929<div><p class="copyright">Copyright © 2009 Christian Schladetsch</p></div>
    3030<div><div class="legalnotice" title="Legal Notice">
    31 <a name="id687319"></a><p>
     31<a name="id684042"></a><p>
    3232        Distributed under the Boost Software License, Version 1.0. (See accompanying
    3333        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
     
    7575</div>
    7676<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
    77 <td align="left"><p><small>Last revised: July 04, 2009 at 23:19:19 GMT</small></p></td>
     77<td align="left"><p><small>Last revised: July 05, 2009 at 00:14:51 GMT</small></p></td>
    7878<td align="right"><div class="copyright-footer"></div></td>
    7979</tr></table>
  • sandbox/cloneable/libs/cloneable/test/tests.cpp

    r54658 r54660  
    594594                my_base(int n = 0) : number(n) { }
    595595                virtual ~my_base() { }
     596                bool operator==(my_base const &other) const
     597                {
     598                        return number == other.number;
     599                }
     600                bool operator!=(my_base const &other) const
     601                {
     602                        return number != other.number;
     603                }
    596604                bool operator<(my_base const &other) const
    597605                {
     
    633641BOOST_AUTO_TEST_CASE(test_map)
    634642{
    635         return;
     643        //return;
    636644        using namespace map_test;
    637645        M2 m2;
     
    645653        Map map;
    646654        map.key<M2>().value<M3>();
     655        BOOST_ASSERT(map.size() == 1);
    647656        Map::iterator a = map.find<M2>();
     657        BOOST_ASSERT(a != map.end());
    648658
    649659        map.key<M0>(42).value<M1>("foo");
     660        BOOST_ASSERT(map.size() == 2);
     661
     662        Map::iterator iter = map.find<M0>(42);
     663        BOOST_ASSERT(iter!= map.end());
     664
    650665        map.key<M2>().value<M3>();
    651666
    652         Map::iterator iter = map.find<M0>(42);
    653 
    654         BOOST_ASSERT(iter!= map.end());
    655         M1 *m1 = dynamic_cast<M1 *>(iter->second);
    656         BOOST_ASSERT(m1 != 0);
    657         BOOST_ASSERT(m1->str == "foo");
    658 
    659         Map copy = map;
     667//      Map copy = map;
    660668}
    661669
     
    766774
    767775//EOF
    768 
    769  
Note: See TracChangeset for help on using the changeset viewer.