1 // boost utility.hpp header file -------------------------------------------//
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
9 // See http://www.boost.org for most recent version including documentation.
11 // Classes appear in alphabetical order
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)
22 #ifndef BOOST_UTILITY_HPP
23 #define BOOST_UTILITY_HPP
25 #include <boost/config.hpp>
26 #include <cstddef> // for size_t
27 #include <utility> // for std::pair
33 // next() and prior() template functions -----------------------------------//
35 // Helper functions for classes like bidirectional iterators not supporting
36 // operator+ and operator-.
39 // const std::list<T>::iterator p = get_some_iterator();
40 // const std::list<T>::iterator prev = boost::prior(p);
42 // Contributed by Dave Abrahams
45 T next(T x) { return ++x; }
48 T prior(T x) { return --x; }
51 // class noncopyable -------------------------------------------------------//
53 // Private copy constructor and copy assignment ensure classes derived from
54 // class noncopyable cannot be copied.
56 // Contributed by Dave Abrahams
63 private: // emphasize the following members are private
64 noncopyable( const noncopyable& );
65 const noncopyable& operator=( const noncopyable& );
68 // class tied -------------------------------------------------------//
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.
74 // Constributed by Jeremy Siek
76 template <class A, class B>
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) {
91 template <class A, class B>
92 inline tied<A,B> tie(A& a, B& b) { return tied<A,B>(a, b); }
95 //} // namespace boost
97 #endif // BOOST_UTILITY_HPP