]> git.lyx.org Git - lyx.git/blob - boost/boost/utility.hpp
cvsignore ++
[lyx.git] / boost / boost / utility.hpp
1 //  boost utility.hpp header file  -------------------------------------------//
2
3 //  (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
4 //  and distribute this software is granted provided this copyright
5 //  notice appears in all copies. This software is provided "as is" without
6 //  express or implied warranty, and with no claim as to its suitability for
7 //  any purpose.
8
9 //  See http://www.boost.org for most recent version including documentation.
10
11 //  Classes appear in alphabetical order
12
13 //  Revision History
14 //  26 Jan 00  protected noncopyable destructor added (Miki Jovanovic)
15 //  10 Dec 99  next() and prior() templates added (Dave Abrahams)
16 //  30 Aug 99  moved cast templates to cast.hpp (Beman Dawes)
17 //   3 Aug 99  cast templates added
18 //  20 Jul 99  name changed to utility.hpp 
19 //   9 Jun 99  protected noncopyable default ctor
20 //   2 Jun 99  Initial Version. Class noncopyable only contents (Dave Abrahams)
21
22 #ifndef BOOST_UTILITY_HPP
23 #define BOOST_UTILITY_HPP
24
25 #include <boost/config.hpp>
26 #include <cstddef>            // for size_t
27 #include <utility>            // for std::pair
28
29 // LGB
30 //namespace boost
31 //{
32
33 //  next() and prior() template functions  -----------------------------------//
34
35     //  Helper functions for classes like bidirectional iterators not supporting
36     //  operator+ and operator-.
37     //
38     //  Usage:
39     //    const std::list<T>::iterator p = get_some_iterator();
40     //    const std::list<T>::iterator prev = boost::prior(p);
41
42     //  Contributed by Dave Abrahams
43
44     template <class T>
45     T next(T x) { return ++x; }
46
47     template <class T>
48     T prior(T x) { return --x; }
49
50
51 //  class noncopyable  -------------------------------------------------------//
52
53     //  Private copy constructor and copy assignment ensure classes derived from
54     //  class noncopyable cannot be copied.
55
56     //  Contributed by Dave Abrahams
57
58     class noncopyable
59     {
60     protected:
61         noncopyable(){}
62         ~noncopyable(){}
63     private:  // emphasize the following members are private
64         noncopyable( const noncopyable& );
65         const noncopyable& operator=( const noncopyable& );
66     }; // noncopyable
67
68 //  class tied  -------------------------------------------------------//
69
70     // A helper for conveniently assigning the two values from a pair
71     // into separate variables. The idea for this comes from Jaakko J\84rvi's
72     // Binder/Lambda Library.
73
74     // Constributed by Jeremy Siek
75
76     template <class A, class B>
77     class tied {
78     public:
79       inline tied(A& a, B& b) : _a(a), _b(b) { }
80       template <class U, class V>
81       inline tied& operator=(const std::pair<U,V>& p) {
82         _a = p.first;
83         _b = p.second;
84         return *this;
85       }
86     protected:
87       A& _a;
88       B& _b;
89     };
90
91     template <class A, class B>
92     inline tied<A,B> tie(A& a, B& b) { return tied<A,B>(a, b); }
93
94 // LGB
95 //} // namespace boost
96
97 #endif  // BOOST_UTILITY_HPP
98
99
100
101