diff --git a/index.html b/index.html index eb4d6ad..f49e437 100644 --- a/index.html +++ b/index.html @@ -21,14 +21,13 @@ compressed_pair
iterator_adaptors
operators
- tie
throw_exception
utility
value_init


Revised - 09 January, 2003

+ 01 September, 2003

 

- \ No newline at end of file + diff --git a/tie.html b/tie.html deleted file mode 100644 index 14219b4..0000000 --- a/tie.html +++ /dev/null @@ -1,143 +0,0 @@ - - - -Boost Tie - -C++ Boost - -
- -

-tie -

- -

-[This version of tie has been removed from the utility.hpp -header.  There is a new, more general version of tie in the Boost -Tuples Library. The more general version handles an (almost) arbitrary -number of arguments, instead of just two. The version in utility.hpp -had to be removed to avoid name clashes.]

-
-template <class A, class B>
-tied<A,B> tie(A& a, B& b);
-
- -

-This is a utility function that makes it more convenient to work with -a function which returns a std::pair<>. The effect of the tie() -function is to allow the assignment of the two values of the pair to -two separate variables. The idea for this comes from Jaakko -Järvi's Binders [1]. - -

- -

Where Defined

- -

-boost/utility.hpp - -

- -

Example

- -

-An example of using the tie() function with the -vertices() function, which returns a pair of -type std::pair<vertex_iterator,vertex_iterator>. The -pair of iterators is assigned to the iterator variables i and -end. - -

-

-  graph_traits< adjacency_list<> >::vertex_iterator i, end;
-  for(tie(i,end) = vertices(G); i != end; ++i)
-    // ...
-
- -

-Here is another example that uses tie() for handling operations with std::set. - -

-

-#include <set>
-#include <algorithm>
-#include <iostream>
-#include <boost/utility.hpp>
-
-int
-main(int, char*[])
-{
-  {
-    typedef std::set<int> SetT;
-    SetT::iterator i, end;
-    bool inserted;
-    
-    int vals[5] = { 5, 2, 4, 9, 1 };
-    SetT s(vals, vals + 5);
-    
-    // Using tie() with a return value of pair<iterator,bool>
-
-    int new_vals[2] = { 3, 9 };
-
-    for (int k = 0; k < 2; ++k) {
-      boost::tie(i,inserted) = s.insert(new_vals[k]);
-      if (!inserted)
-        std::cout << *i << " was already in the set." << std::endl;
-      else
-        std::cout << *i << " successfully inserted." << std::endl;    
-    }
-  }    
-  {
-    int* i, *end;
-    int vals[6] = { 5, 2, 4, 4, 9, 1 };
-    std::sort(vals, vals + 6);
-
-    // Using tie() with a return value of pair<iterator,iterator>
-
-    boost::tie(i,end) = std::equal_range(vals, vals + 6, 4);
-    std::cout << "There were " << std::distance(i,end)
-              << " occurrences of " << *i << "." << std::endl;
-    // Footnote: of course one would normally just use std::count()
-    // to get this information, but that would spoil the example :)
-  }
-  return 0;
-}
-
-The output is: -
-  3 successfully inserted.
-  9 was already in the set.
-  There were 2 occurrences of 4.
-
- -
-
- - -
Copyright © 2000 -Jeremy Siek, -Univ.of Notre Dame (jsiek@lsc.nd.edu)
-Lie-Quan Lee, Univ.of Notre Dame (llee1@lsc.nd.edu)
-Andrew Lumsdaine, -Univ.of Notre Dame (lums@lsc.nd.edu) -
- - - diff --git a/tie_example.cpp b/tie_example.cpp deleted file mode 100644 index a2462df..0000000 --- a/tie_example.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify, -// sell and distribute this software is granted provided this -// copyright notice appears in all copies. This software is provided -// "as is" without express or implied warranty, and with no claim as -// to its suitability for any purpose. -// -// This is an example demonstrating how to use the tie() function. -// The purpose of tie() is to make it easiery to deal with std::pair -// return values. -// -// Contributed by Jeremy Siek -// -// Sample output -// -// 3 successfully inserted. -// 9 was already in the set. -// There were 2 occurrences of 4. - -#include -#include -#include -#include // std::distance -// Note: tie() use to live in boost/utility.hpp, but -// not it is part of the more general Boost Tuple Library. -#include - -int -main(int, char*[]) -{ - { - typedef std::set SetT; - SetT::iterator i; - bool inserted; - - int vals[5] = { 5, 2, 4, 9, 1 }; - SetT s(vals, vals + 5); - - // Using tie() with a return value of pair - - int new_vals[2] = { 3, 9 }; - - for (int k = 0; k < 2; ++k) { - boost::tie(i,inserted) = s.insert(new_vals[k]); - if (!inserted) - std::cout << *i << " was already in the set." << std::endl; - else - std::cout << *i << " successfully inserted." << std::endl; - } - } - { - int* i, *end; - int vals[6] = { 5, 2, 4, 4, 9, 1 }; - std::sort(vals, vals + 6); - - // Using tie() with a return value of pair - - boost::tie(i,end) = std::equal_range(vals, vals + 6, 4); - std::cout << "There were " << std::distance(i,end) - << " occurrences of " << *i << "." << std::endl; - // Footnote: of course one would normally just use std::count() - // to get this information, but that would spoil the example :) - } - return 0; -} diff --git a/utility.htm b/utility.htm index 8aa7a2c..9f0a6ca 100644 --- a/utility.htm +++ b/utility.htm @@ -22,8 +22,6 @@ Class noncopyable
  • Function template addressof()
  • -
  • - Function template tie() and supporting class tied.
  • Function templates checked_delete() and @@ -122,16 +120,14 @@ void f() {

    Class templates for the Base-from-Member Idiom

    See separate documentation.

    -

    Function template tie()

    -

    See separate documentation.


    Revised  09 January, 200301 September, 2003

    -

    © Copyright boost.org 1999-2002. Permission to copy, use, modify, sell and distribute +

    © Copyright boost.org 1999-2003. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.

    - \ No newline at end of file +