Skip to content

Commit 9ebd93a

Browse files
derekmaurocopybara-github
authored andcommitted
Remove the implementation of absl::string_view, which was only needed
prior to C++17. `absl::string_view` is now an alias for `std::string_view`. It is recommended that clients simply use `std::string_view`. PiperOrigin-RevId: 845822478 Change-Id: I220530c84118e5b9ef110baa002c232ac8f2c5f2
1 parent d2dd9b9 commit 9ebd93a

File tree

10 files changed

+10
-2796
lines changed

10 files changed

+10
-2796
lines changed

CMake/AbseilDll.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ set(ABSL_INTERNAL_DLL_FILES
345345
"strings/str_replace.h"
346346
"strings/str_split.cc"
347347
"strings/str_split.h"
348-
"strings/string_view.cc"
349-
"strings/string_view.h"
350348
"strings/strip.h"
351349
"strings/substitute.cc"
352350
"strings/substitute.h"
@@ -446,6 +444,7 @@ set(ABSL_INTERNAL_DLL_FILES
446444
"types/variant.h"
447445
"utility/utility.h"
448446
"debugging/leak_check.cc"
447+
"strings/string_view.h"
449448
)
450449

451450
if(MSVC)

absl/base/config.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,11 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
526526
#define ABSL_USES_STD_ANY 1
527527
#define ABSL_HAVE_STD_OPTIONAL 1
528528
#define ABSL_USES_STD_OPTIONAL 1
529+
#define ABSL_HAVE_STD_STRING_VIEW 1
530+
#define ABSL_USES_STD_STRING_VIEW 1
529531
#define ABSL_HAVE_STD_VARIANT 1
530532
#define ABSL_USES_STD_VARIANT 1
531533

532-
// ABSL_HAVE_STD_STRING_VIEW
533-
//
534-
// Deprecated: always defined to 1.
535-
// std::string_view was added in C++17, which means all versions of C++
536-
// supported by Abseil have it.
537-
#ifdef ABSL_HAVE_STD_STRING_VIEW
538-
#error "ABSL_HAVE_STD_STRING_VIEW cannot be directly set."
539-
#else
540-
#define ABSL_HAVE_STD_STRING_VIEW 1
541-
#endif
542-
543534
// ABSL_HAVE_STD_ORDERING
544535
//
545536
// Checks whether C++20 std::{partial,weak,strong}_ordering are available.
@@ -556,20 +547,6 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
556547
#define ABSL_HAVE_STD_ORDERING 1
557548
#endif
558549

559-
// ABSL_USES_STD_STRING_VIEW
560-
//
561-
// Indicates whether absl::string_view is an alias for std::string_view.
562-
#if !defined(ABSL_OPTION_USE_STD_STRING_VIEW)
563-
#error options.h is misconfigured.
564-
#elif ABSL_OPTION_USE_STD_STRING_VIEW == 0
565-
#undef ABSL_USES_STD_STRING_VIEW
566-
#elif ABSL_OPTION_USE_STD_STRING_VIEW == 1 || \
567-
ABSL_OPTION_USE_STD_STRING_VIEW == 2
568-
#define ABSL_USES_STD_STRING_VIEW 1
569-
#else
570-
#error options.h is misconfigured.
571-
#endif
572-
573550
// ABSL_USES_STD_ORDERING
574551
//
575552
// Indicates whether absl::{partial,weak,strong}_ordering are aliases for the

absl/base/options.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,6 @@
7373
// Type Compatibility Options
7474
// -----------------------------------------------------------------------------
7575

76-
// ABSL_OPTION_USE_STD_STRING_VIEW
77-
//
78-
// This option controls whether absl::string_view is implemented as an alias to
79-
// std::string_view, or as an independent implementation.
80-
//
81-
// A value of 0 means to use Abseil's implementation. This requires only C++11
82-
// support, and is expected to work on every toolchain we support.
83-
//
84-
// A value of 1 means to use an alias to std::string_view. This requires that
85-
// all code using Abseil is built in C++17 mode or later.
86-
//
87-
// A value of 2 means to detect the C++ version being used to compile Abseil,
88-
// and use an alias only if a working std::string_view is available. This
89-
// option is useful when you are building your program from source. It should
90-
// not be used otherwise -- for example, if you are distributing Abseil in a
91-
// binary package manager -- since in mode 2, absl::string_view will name a
92-
// different type, with a different mangled name and binary layout, depending on
93-
// the compiler flags passed by the end user. For more info, see
94-
// https://abseil.io/about/design/dropin-types.
95-
//
96-
// User code should not inspect this macro. To check in the preprocessor if
97-
// absl::string_view is a typedef of std::string_view, use the feature macro
98-
// ABSL_USES_STD_STRING_VIEW.
99-
100-
#define ABSL_OPTION_USE_STD_STRING_VIEW 2
101-
10276
// ABSL_OPTION_USE_STD_ORDERING
10377
//
10478
// This option controls whether absl::{partial,weak,strong}_ordering are

absl/strings/BUILD.bazel

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ licenses(["notice"])
3636

3737
cc_library(
3838
name = "string_view",
39-
srcs = ["string_view.cc"],
4039
hdrs = ["string_view.h"],
4140
copts = ABSL_DEFAULT_COPTS,
4241
linkopts = ABSL_DEFAULT_LINKOPTS,
4342
deps = [
44-
"//absl/base",
4543
"//absl/base:config",
4644
"//absl/base:core_headers",
4745
"//absl/base:nullability",
48-
"//absl/base:throw_delegate",
4946
],
5047
)
5148

@@ -410,23 +407,6 @@ cc_test(
410407
],
411408
)
412409

413-
cc_binary(
414-
name = "string_view_benchmark",
415-
testonly = True,
416-
srcs = ["string_view_benchmark.cc"],
417-
copts = ABSL_TEST_COPTS,
418-
tags = ["benchmark"],
419-
visibility = ["//visibility:private"],
420-
deps = [
421-
":string_view",
422-
":strings",
423-
"//absl/base:core_headers",
424-
"//absl/base:raw_logging_internal",
425-
"//absl/random",
426-
"@google_benchmark//:benchmark_main",
427-
],
428-
)
429-
430410
cc_test(
431411
name = "string_view_test",
432412
size = "small",

absl/strings/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ absl_cc_library(
1919
string_view
2020
HDRS
2121
"string_view.h"
22-
SRCS
23-
"string_view.cc"
2422
COPTS
2523
${ABSL_DEFAULT_COPTS}
2624
DEPS
27-
absl::base
2825
absl::config
2926
absl::core_headers
3027
absl::nullability
31-
absl::throw_delegate
3228
PUBLIC
3329
)
3430

0 commit comments

Comments
 (0)