Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:01:16

0001 // Copyright 2022 The Abseil Authors
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //     https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 
0015 #ifndef ABSL_STRINGS_HAS_ABSL_STRINGIFY_H_
0016 #define ABSL_STRINGS_HAS_ABSL_STRINGIFY_H_
0017 
0018 #include <type_traits>
0019 #include <utility>
0020 
0021 #include "absl/strings/string_view.h"
0022 
0023 namespace absl {
0024 ABSL_NAMESPACE_BEGIN
0025 
0026 namespace strings_internal {
0027 
0028 // This is an empty class not intended to be used. It exists so that
0029 // `HasAbslStringify` can reference a universal class rather than needing to be
0030 // copied for each new sink.
0031 class UnimplementedSink {
0032  public:
0033   void Append(size_t count, char ch);
0034 
0035   void Append(string_view v);
0036 
0037   // Support `absl::Format(&sink, format, args...)`.
0038   friend void AbslFormatFlush(UnimplementedSink* sink, absl::string_view v);
0039 };
0040 
0041 }  // namespace strings_internal
0042 
0043 // `HasAbslStringify<T>` detects if type `T` supports the `AbslStringify()`
0044 // customization point (see
0045 // https://abseil.io/docs/cpp/guides/format#abslstringify for the
0046 // documentation).
0047 //
0048 // Note that there are types that can be `StrCat`-ed that do not use the
0049 // `AbslStringify` customization point (for example, `int`).
0050 
0051 template <typename T, typename = void>
0052 struct HasAbslStringify : std::false_type {};
0053 
0054 template <typename T>
0055 struct HasAbslStringify<
0056     T, std::enable_if_t<std::is_void<decltype(AbslStringify(
0057            std::declval<strings_internal::UnimplementedSink&>(),
0058            std::declval<const T&>()))>::value>> : std::true_type {};
0059 
0060 ABSL_NAMESPACE_END
0061 }  // namespace absl
0062 
0063 #endif  // ABSL_STRINGS_HAS_ABSL_STRINGIFY_H_