ref.qbk 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. [/
  2. / Copyright (c) 2001, 2002, 2006 Peter Dimov
  3. / Copyright (c) 2002 David Abrahams
  4. / Copyright (c) 2002 Aleksey Gurtovoy
  5. / Copyright (c) 2003, 2004 Douglas Gregor
  6. / Copyright (c) 2009 Ronald Garcia
  7. / Copyright (c) 2014 Glen Joseph Fernandes
  8. /
  9. / Distributed under the Boost Software License, Version 1.0. (See
  10. / accompanying file LICENSE_1_0.txt or copy at
  11. / http://www.boost.org/LICENSE_1_0.txt)
  12. /]
  13. [section:ref ref]
  14. [simplesect Authors]
  15. * Jaakko J\u00E4rvi
  16. * Peter Dimov
  17. * Douglas Gregor
  18. * Dave Abrahams
  19. * Frank Mori Hess
  20. * Ronald Garcia
  21. [endsimplesect]
  22. [section Introduction]
  23. The Ref library is a small library that is useful for passing
  24. references to function templates (algorithms) that would
  25. usually take copies of their arguments. It defines the class
  26. template `boost::reference_wrapper<T>`, two functions
  27. `boost::ref` and `boost::cref` that return instances of
  28. `boost::reference_wrapper<T>`, a function `boost::unwrap_ref`
  29. that unwraps a `boost::reference_wrapper<T>` or returns a
  30. reference to any other type of object, and the two traits
  31. classes `boost::is_reference_wrapper<T>` and
  32. `boost::unwrap_reference<T>`.
  33. The purpose of `boost::reference_wrapper<T>` is to contain a
  34. reference to an object of type `T`. It is primarily used to
  35. "feed" references to function templates (algorithms) that take
  36. their parameter by value.
  37. To support this usage, `boost::reference_wrapper<T>` provides
  38. an implicit conversion to `T&`. This usually allows the
  39. function templates to work on references unmodified.
  40. `boost::reference_wrapper<T>` is both CopyConstructible and
  41. Assignable (ordinary references are not Assignable).
  42. The `expression boost::ref(x)` returns a
  43. `boost::reference_wrapper<X>(x)` where `X` is the type of `x`.
  44. Similarly, `boost::cref(x)` returns a
  45. `boost::reference_wrapper<X const>(x)`.
  46. The expression `boost::unwrap_ref(x)` returns a
  47. `boost::unwrap_reference<X>::type&` where `X` is the type of
  48. `x`.
  49. The expression `boost::is_reference_wrapper<T>::value` is
  50. `true` if `T` is a `reference_wrapper`, and `false` otherwise.
  51. The type-expression `boost::unwrap_reference<T>::type` is
  52. `T::type` if `T` is a `reference_wrapper`, `T` otherwise.
  53. [endsect]
  54. [xinclude ref_reference.xml]
  55. [section Acknowledgments]
  56. `ref` and `cref` were originally part of the Tuple library by
  57. Jaakko J\u00E4rvi. They were "promoted to `boost::` status" by
  58. Peter Dimov because they are generally useful. Douglas Gregor
  59. and Dave Abrahams contributed `is_reference_wrapper` and
  60. `unwrap_reference`. Frank Mori Hess and Ronald Garcia
  61. contributed `boost::unwrap_ref`.
  62. [endsect]
  63. [endsect]