LCOV - code coverage report
Current view: top level - snapdev - not_used.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 5 100.0 %
Date: 2023-05-29 16:11:08 Functions: 8 14 57.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011-2023  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/snapdev
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software: you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation, either version 3 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License
      17             : // along with this program.  If not, see <https://www.gnu.org/licenses/>.
      18             : #pragma once
      19             : 
      20             : /** \file
      21             :  * \brief Functions used to mark variables as unused.
      22             :  *
      23             :  * One drawback of C++ is that at times we have overloaded functions that
      24             :  * include parameters that end up not being used. By default, this generates
      25             :  * a warning in our environment. This is actually very useful to either
      26             :  * remove the unused parameter or notice the fact that we used the wrong
      27             :  * parameter somewhere in our function.
      28             :  *
      29             :  * There are times, though, when the parameter is expected to not be used
      30             :  * In those cases, this function is useful to \em hide the parameter:
      31             :  *
      32             :  * \code
      33             :  *     snapdev::NOT_USED(param);
      34             :  *     // or with multiple parameters
      35             :  *     snapdev::NOT_USED(param1, param2, ..., paramN);
      36             :  * \endcode
      37             :  */
      38             : 
      39             : namespace snapdev
      40             : {
      41             : 
      42             : 
      43             : [[deprecated]] inline constexpr void NOTUSED()
      44             : {
      45             : }
      46             : 
      47             : 
      48             : template <class T, class ...ARGS>
      49             : [[deprecated]] inline constexpr void NOTUSED( T && first, ARGS && ...args )
      50             : {
      51             : #pragma GCC diagnostic push
      52             : #pragma GCC diagnostic ignored "-Wunused-result"
      53             :     static_cast<void>( first );
      54             : #pragma GCC diagnostic pop
      55             :     NOTUSED(args...);
      56             : }
      57             : 
      58             : 
      59        4312 : inline constexpr void NOT_USED()
      60             : {
      61        4312 : }
      62             : 
      63             : 
      64             : template <class T, class ...ARGS>
      65        4362 : inline constexpr void NOT_USED( T && first, ARGS && ...args )
      66             : {
      67             : #pragma GCC diagnostic push
      68             : #pragma GCC diagnostic ignored "-Wunused-result"
      69             :     static_cast<void>( first );
      70             : #pragma GCC diagnostic pop
      71        4362 :     NOT_USED(args...);
      72        4362 : }
      73             : 
      74             : 
      75             : 
      76             : } // namespace snapdev
      77             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.14