tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

voidify.h (1735B)


      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 does the dispatching of the completed `absl::LogEntry` to
     20 // applicable `absl::LogSink`s, and is used to explicitly ignore values in the
     21 // conditional logging macros. This avoids compiler warnings like "value
     22 // computed is not used" and "statement has no effect".
     23 
     24 #ifndef ABSL_LOG_INTERNAL_VOIDIFY_H_
     25 #define ABSL_LOG_INTERNAL_VOIDIFY_H_
     26 
     27 #include "absl/base/attributes.h"
     28 #include "absl/base/config.h"
     29 
     30 namespace absl {
     31 ABSL_NAMESPACE_BEGIN
     32 namespace log_internal {
     33 
     34 class Voidify final {
     35 public:
     36  // This has to be an operator with a precedence lower than << but higher than
     37  // ?:
     38  template <typename T>
     39  ABSL_ATTRIBUTE_COLD void operator&&(T&& message) const&& {
     40    // The dispatching of the completed `absl::LogEntry` to applicable
     41    // `absl::LogSink`s happens here.
     42    message.Flush();
     43  }
     44 };
     45 
     46 }  // namespace log_internal
     47 ABSL_NAMESPACE_END
     48 }  // namespace absl
     49 
     50 #endif  // ABSL_LOG_INTERNAL_VOIDIFY_H_