| 1 | // Copyright 2022 The Abseil Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | // |
| 15 | // ----------------------------------------------------------------------------- |
| 16 | // File: log/internal/voidify.h |
| 17 | // ----------------------------------------------------------------------------- |
| 18 | // |
| 19 | // This class is used to explicitly ignore values in the conditional logging |
| 20 | // macros. This avoids compiler warnings like "value computed is not used" and |
| 21 | // "statement has no effect". |
| 22 | |
| 23 | #ifndef ABSL_LOG_INTERNAL_VOIDIFY_H_ |
| 24 | #define ABSL_LOG_INTERNAL_VOIDIFY_H_ |
| 25 | |
| 26 | #include "absl/base/config.h" |
| 27 | |
| 28 | namespace absl { |
| 29 | ABSL_NAMESPACE_BEGIN |
| 30 | namespace log_internal { |
| 31 | |
| 32 | class Voidify final { |
| 33 | public: |
| 34 | // This has to be an operator with a precedence lower than << but higher than |
| 35 | // ?: |
| 36 | template <typename T> |
| 37 | void operator&&(const T&) const&& {} |
| 38 | }; |
| 39 | |
| 40 | } // namespace log_internal |
| 41 | ABSL_NAMESPACE_END |
| 42 | } // namespace absl |
| 43 | |
| 44 | #endif // ABSL_LOG_INTERNAL_VOIDIFY_H_ |
| 45 | |