voidify.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef ABSL_LOG_INTERNAL_VOIDIFY_H_
  23. #define ABSL_LOG_INTERNAL_VOIDIFY_H_
  24. #include "absl/base/config.h"
  25. namespace absl {
  26. ABSL_NAMESPACE_BEGIN
  27. namespace log_internal {
  28. class Voidify final {
  29. public:
  30. // This has to be an operator with a precedence lower than << but higher than
  31. // ?:
  32. template <typename T>
  33. void operator&&(const T&) const&& {}
  34. };
  35. } // namespace log_internal
  36. ABSL_NAMESPACE_END
  37. } // namespace absl
  38. #endif // ABSL_LOG_INTERNAL_VOIDIFY_H_