add_reference.qbk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. [/
  2. Copyright 2007 John Maddock.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ]
  7. [section:add_reference add_reference]
  8. [note This trait has been made obsolete by __add_lvalue_reference and __add_rvalue_reference,
  9. and new code should use these new traits rather than __is_reference which is retained
  10. for backwards compatibility only.
  11. ]
  12. template <class T>
  13. struct add_reference
  14. {
  15. typedef __below type;
  16. };
  17. template <class T> using add_reference_t = typename add_reference<T>::type; // C++11 and above
  18. __type If `T` is not a reference type then `T&`, otherwise `T`.
  19. __std_ref 8.3.2.
  20. __header ` #include <boost/type_traits/add_reference.hpp>` or ` #include <boost/type_traits.hpp>`
  21. [table Examples
  22. [ [Expression] [Result Type]]
  23. [[`add_reference<int>::type`][`int&`]]
  24. [[`add_reference<int const&>::type`] [`int const&`]]
  25. [[`add_reference<int*>::type`] [`int*&`]]
  26. [[`add_reference<int*&>::type`] [`int*&`]]
  27. ]
  28. [all_compilers]
  29. [endsect]