![]() |
|
|||
File indexing completed on 2025-07-12 08:06:48
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/base/config.h" 0022 #include "absl/strings/string_view.h" 0023 0024 namespace absl { 0025 ABSL_NAMESPACE_BEGIN 0026 0027 namespace strings_internal { 0028 0029 // This is an empty class not intended to be used. It exists so that 0030 // `HasAbslStringify` can reference a universal class rather than needing to be 0031 // copied for each new sink. 0032 class UnimplementedSink { 0033 public: 0034 void Append(size_t count, char ch); 0035 0036 void Append(string_view v); 0037 0038 // Support `absl::Format(&sink, format, args...)`. 0039 friend void AbslFormatFlush(UnimplementedSink* sink, absl::string_view v); 0040 }; 0041 0042 } // namespace strings_internal 0043 0044 // `HasAbslStringify<T>` detects if type `T` supports the `AbslStringify()` 0045 // customization point (see 0046 // https://abseil.io/docs/cpp/guides/format#abslstringify for the 0047 // documentation). 0048 // 0049 // Note that there are types that can be `StrCat`-ed that do not use the 0050 // `AbslStringify` customization point (for example, `int`). 0051 0052 template <typename T, typename = void> 0053 struct HasAbslStringify : std::false_type {}; 0054 0055 template <typename T> 0056 struct HasAbslStringify< 0057 T, std::enable_if_t<std::is_void<decltype(AbslStringify( 0058 std::declval<strings_internal::UnimplementedSink&>(), 0059 std::declval<const T&>()))>::value>> : std::true_type {}; 0060 0061 ABSL_NAMESPACE_END 0062 } // namespace absl 0063 0064 #endif // ABSL_STRINGS_HAS_ABSL_STRINGIFY_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |