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
32 // next() and prior() template functions -----------------------------------//
34 // Helper functions for classes like bidirectional iterators not supporting
35 // operator+ and operator-.
38 // const std::list<T>::iterator p = get_some_iterator();
39 // const std::list<T>::iterator prev = boost::prior(p);
41 // Contributed by Dave Abrahams
44 T next(T x) { return ++x; }
47 T prior(T x) { return --x; }
50 // class noncopyable -------------------------------------------------------//
52 // Private copy constructor and copy assignment ensure classes derived from
53 // class noncopyable cannot be copied.
55 // Contributed by Dave Abrahams
62 private: // emphasize the following members are private
63 noncopyable( const noncopyable& );
64 const noncopyable& operator=( const noncopyable& );
67 // class tied -------------------------------------------------------//
69 // A helper for conveniently assigning the two values from a pair
70 // into separate variables. The idea for this comes from Jaakko J
\84rvi's
71 // Binder/Lambda Library.
73 // Constributed by Jeremy Siek
75 template <class A, class B>
78 inline tied(A& a, B& b) : _a(a), _b(b) { }
79 template <class U, class V>
80 inline tied& operator=(const std::pair<U,V>& p) {
90 template <class A, class B>
91 inline tied<A,B> tie(A& a, B& b) { return tied<A,B>(a, b); }
95 #endif // BOOST_UTILITY_HPP