Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/ptr_container/test/tut34.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

  • Property svn:executable set to *
File size: 1.4 KB
Line 
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#include <boost/ptr_container/ptr_sequence_adapter.hpp>
13#include <vector>
14#include <boost/ptr_container/ptr_map_adapter.hpp>
15#include <map>
16
17template< class T >
18struct my_ptr_vector : 
19    public boost::ptr_sequence_adapter< std::vector<T*> >
20{
21
22};
23
24   
25template< class Key, class T, class Pred = std::less<Key>,
26          class Allocator = std::allocator< std::pair<const Key, T> > >
27struct my_map : public std::map<Key,T,Pred,Allocator>
28{
29    explicit my_map( const Pred&      pred  = Pred(), 
30                     const Allocator& alloc = Allocator() ) 
31    { }
32};
33
34#include <string>
35struct Foo {};
36
37typedef boost::ptr_map_adapter< my_map<std::string,Foo*> > foo_map;
38
39template< class Key, class T, class Pred = std::less<Key> >
40struct my_ptr_map : public boost::ptr_map_adapter< std::map<Key,T*,Pred> >
41{
42
43};
44
45typedef my_ptr_map<std::string,Foo> foo_map2;
46   
47
48int main()
49{
50   
51    my_ptr_vector<Foo> vec;
52    vec.push_back( new Foo );
53    foo_map  m1;
54    foo_map2 m2;
55    std::string s("");
56    m1.insert( s, new Foo );
57    m2.insert( s, new Foo );
58
59   
60}
61
Note: See TracBrowser for help on using the repository browser.