ignore_unused.qbk 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [/
  2. Copyright 2014 Adam Wulkiewicz
  3. Distributed under the Boost Software License, Version 1.0.
  4. See accompanying file LICENSE_1_0.txt
  5. or copy at http://boost.org/LICENSE_1_0.txt
  6. ]
  7. [section:ignore_unused ignore_unused]
  8. [simplesect Authors]
  9. * Adam Wulkiewicz
  10. [endsimplesect]
  11. [section Header <boost/core/ignore_unused.hpp>]
  12. The header `<boost/core/ignore_unused.hpp>` defines the function template
  13. `boost::ignore_unused()`. It may be used to suppress the "unused variable" or
  14. "unused local typedefs" compiler warnings when the variable or typedef
  15. can't be removed or commented out, e.g. when some blocks of the code are
  16. conditionally activated. C++11 variadic templates are used if they're supported,
  17. otherwise they're emulated with overloads.
  18. [section Usage]
  19. ``
  20. boost::ignore_unused(v1, v2, v3);
  21. boost::ignore_unused<T1, T2, T3>();
  22. ``
  23. [endsect]
  24. [section Example]
  25. ``
  26. int fun( int foo, int bar )
  27. {
  28. boost::ignore_unused(bar);
  29. #ifdef ENABLE_DEBUG_OUTPUT
  30. if ( foo < bar )
  31. std::cerr << "warning! foo < bar";
  32. #endif
  33. return foo + 2;
  34. }
  35. ``
  36. [endsect]
  37. [endsect]
  38. [section Acknowledgments]
  39. `boost::ignore_unused()` was contributed by Adam Wulkiewicz.
  40. [endsect]
  41. [endsect]