diff --git a/include/boost/utility.hpp b/include/boost/utility.hpp index 44dd5d8..43ddb72 100644 --- a/include/boost/utility.hpp +++ b/include/boost/utility.hpp @@ -63,6 +63,32 @@ namespace boost const noncopyable& operator=( const noncopyable& ); }; // noncopyable +// class tied -------------------------------------------------------// + + // A helper for conveniently assigning the two values from a pair + // into separate variables. The idea for this comes from Jaakko J„rvi's + // Binder/Lambda Library. + + // Constributed by Jeremy Siek + + template + class tied { + public: + inline tied(A& a, B& b) : _a(a), _b(b) { } + template + inline tied& operator=(const std::pair& p) { + _a = p.first; + _b = p.second; + return *this; + } + protected: + A& _a; + B& _b; + }; + + template + inline tied tie(A& a, B& b) { return tied(a, b); } + } // namespace boost #endif // BOOST_UTILITY_HPP