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