Add boost::ignore_unused()

This commit is contained in:
Adam Wulkiewicz committed 2014-06-02 15:06:53 +02:00
1 parent b36712f765
commit 61cc397be8
5 files changed
+173

No files matched your search

+5
View File
@@ -37,6 +37,10 @@ Currently, the Core library contains:
[[@../../enable_if.html enable_if]]
[`boost::enable_if`]
]
[
[[link core.ignore_unused ignore_unused]]
[`boost::ignore_unused`]
]
[
[[link core.lightweight_test lightweight_test]]
[`BOOST_TEST, BOOST_ERROR, BOOST_TEST_EQ, BOOST_TEST_NE,
@@ -74,6 +78,7 @@ Currently, the Core library contains:
[include:core addressof.qbk]
[include:core explicit_operator_bool.qbk]
[include:core ignore_unused.qbk]
[include:core lightweight_test.qbk]
[include:core no_exceptions_support.qbk]
[include:core noncopyable.qbk]
+29
View File
@@ -0,0 +1,29 @@
[section:ignore_unused Header <boost/core/ignore_unused.hpp>]
The header `<boost/core/ignore_unused.hpp>` defines the function template
`boost::ignore_unused()`. It may be used to suppress the "unused variable" or
"unused local typedefs" compiler warnings when the variable or typedef
can't be removed or commented out, e.g. when some blocks of the code are
conditionally activated. C++11 variadic templates are used if they're supported,
otherwise they're emulated with overloads.
`boost::ignore_unused()` was contributed by Adam Wulkiewicz.
Usage
boost::ignore_unused(v1, v2, v3);
boost::ignore_unused<T1, T2, T3>();
Example
int fun( int foo, int bar )
{
boost::ignore_unused(bar);
#ifdef ENABLE_DEBUG_OUTPUT
if ( foo < bar )
std::cerr << "warning! foo < bar";
#endif
return foo + 2;
}
[endsect]