Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_
00018 #define ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_
00019
00020 #include <string>
00021 #include <type_traits>
00022 #include <utility>
00023
00024 #include "absl/base/port.h"
00025 #include "absl/meta/type_traits.h"
00026
00027 namespace absl {
00028 namespace strings_internal {
00029
00030
00031
00032 template <typename string_type, typename = void>
00033 struct ResizeUninitializedTraits {
00034 using HasMember = std::false_type;
00035 static void Resize(string_type* s, size_t new_size) { s->resize(new_size); }
00036 };
00037
00038
00039
00040 template <typename string_type>
00041 struct ResizeUninitializedTraits<
00042 string_type, absl::void_t<decltype(std::declval<string_type&>()
00043 .__resize_default_init(237))> > {
00044 using HasMember = std::true_type;
00045 static void Resize(string_type* s, size_t new_size) {
00046 s->__resize_default_init(new_size);
00047 }
00048 };
00049
00050
00051
00052
00053
00054
00055 template <typename string_type>
00056 inline constexpr bool STLStringSupportsNontrashingResize(string_type*) {
00057 return ResizeUninitializedTraits<string_type>::HasMember::value;
00058 }
00059
00060
00061
00062
00063
00064 template <typename string_type, typename = void>
00065 inline void STLStringResizeUninitialized(string_type* s, size_t new_size) {
00066 ResizeUninitializedTraits<string_type>::Resize(s, new_size);
00067 }
00068
00069 }
00070 }
00071
00072 #endif // ABSL_STRINGS_INTERNAL_RESIZE_UNINITIALIZED_H_