24 Commits

Author SHA1 Message Date
Abseil Team
0dc90f01cc Avoid unnecessary absl::void_t usage
PiperOrigin-RevId: 925529542
Change-Id: I19f7795cfad77f6ae0f8396b9a7a794629a8dad1
2026-06-02 12:58:43 -07:00
Abseil Team
0e9e3daf54 Add an overload of absl::c_move to move between containers.
This change introduces a new overload for absl::c_move that takes two ranges, allowing elements to be moved from a source container to a destination container. The destination container must be fixed size so we can perform bounds checking.

PiperOrigin-RevId: 919189227
Change-Id: Ica35c5d8bd59ebe16564f2b2f490770899ad16f8
2026-05-21 12:18:51 -07:00
Abseil Team
ca1d7cb497 Add container overloads for absl::c_copy and absl::c_copy_n
These versions accept a container as the output destination. The primary motivation for these overloads is to add bounds checking. We determine if an object is a container by checking if they support `std::begin`/`std::end`.

PiperOrigin-RevId: 915035028
Change-Id: Ibeb17b784ec313215ba8216a6085628d11eac102
2026-05-13 13:43:47 -07:00
Abseil Team
f9adcd0f0c Add container overloads for absl::c_copy and absl::c_copy_n
These versions accept a container as the output destination. The primary motivation for these overloads is to add bounds checking. We determine if an object is a container by checking if they support `std::begin`/`std::end`.

PiperOrigin-RevId: 907840607
Change-Id: I10430108dc734f1e93c0cef6ca33d251520ac3e8
2026-04-29 16:36:49 -07:00
Abseil Team
a5c21433c7 Add container overloads for absl::c_copy and absl::c_copy_n
These versions accept a container as the output destination. The primary motivation for these overloads is to add bounds checking. We determine if an object is a container by checking if they support `std::begin`/`std::end`.

PiperOrigin-RevId: 907806544
Change-Id: I8830b18df5acad0cd745c7a8d0dd8d1065265c28
2026-04-29 15:24:30 -07:00
Abseil Team
852fc61f31 Remove more lingering C++17 type traits polyfill usages
This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 906360966
Change-Id: Iee362ac0eac647909ef38003280f1179813f764d
2026-04-27 08:03:53 -07:00
Alexandre Vassalotti
747f9c9fd2 Mark Abseil container algorithms as constexpr for C++20.
This conditionally applies `constexpr` to the applicable container-based versions of the <algorithm> functions defined in "absl/algorithm/container.h" when building with C++20 or later.

PiperOrigin-RevId: 800165245
Change-Id: Ie2d0b16b2af84c3abd448ca15306e861d5e6c773
2025-08-27 14:03:53 -07:00
Laramie Leavitt
3870e283fb Use absl::InsecureBitGen in place of std::random_device in Abseil tests.
PiperOrigin-RevId: 750721356
Change-Id: I84e8a1c2a80335983e557270ef78b8b0b4f1e452
2025-04-23 14:16:54 -07:00
Abseil Team
fa588813c4 Make c_find_first_of's options parameter a const reference to allow temporaries.
`c_find_first_of` does not keep or return references into `options` so there's no reason to require an l-value there.

PiperOrigin-RevId: 690696332
Change-Id: Ibbabb69ba72e9506c0406f2124034a944d6899d6
2024-10-28 11:53:04 -07:00
Abseil Team
00478de3e9 Mark non-modifying container algorithms as constexpr for C++20.
This change marks Abseil's non-modifying sequence operations including
absl::linear_search and absl::c_linear_search as constexpr when building with
C++20.
PiperOrigin-RevId: 659812405
Change-Id: I8dc2cee873f30531b2eb8fb3da12085505a43a1a
2024-08-05 22:55:39 -07:00
Abseil Team
074a32af66 Mark c_min_element, c_max_element, and c_minmax_element as constexpr in C++17.
This allows them to be used in constant expressions, such as static_asserts.

PiperOrigin-RevId: 649292841
Change-Id: I76e31a94b933fa357276fee534b81c00c28c8b23
2024-07-03 22:08:39 -07:00
Abseil Team
37ebde53cf Make c_begin, c_end, and c_distance conditionally constexpr.
This allows them to be used in constexpr expressions, such as the following:

```
constexpr int distance = absl::c_distance(std::array<int, 3>());
```

Requires at least C++17 to be constexpr.

PiperOrigin-RevId: 648435141
Change-Id: I8136e351a6dc4c25f06ef895fb449f4f11048480
2024-07-01 11:34:46 -07:00
Abseil Team
63d4b2fe1e Add c_contains() and c_contains_subrange() to absl/algorithm/container.h.
These functions are based on the C++23's `std::ranges::contains()` and `std::ranges::contains_subrange()` functions, see: https://en.cppreference.com/w/cpp/algorithm/ranges/contains

PiperOrigin-RevId: 647084955
Change-Id: If5a01784e3cf1cc4d88e7f2fef92a3701fafc886
2024-06-26 14:46:45 -07:00
Eric Astor
258e5a1575 Add a container-based version of std::sample()
PiperOrigin-RevId: 592864147
Change-Id: I83179b0225aa446ae0b57b46b604af14f1fa14df
2023-12-21 08:12:11 -08:00
Abseil Team
2594f85514 Fix "unsafe narrowing" warnings in absl, 10/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare

(This specific CL focuses on tests.)

Bug: chromium:1292951
PiperOrigin-RevId: 473055916
Change-Id: I40cdd6c87ba9d0a5fb2db5746cff04f14ee829c2
2022-09-08 12:28:51 -07:00
Abseil Team
e63a5a6104 Export of internal Abseil changes
--
430bda42820b619b346201bc42769d014228e825 by Gennadiy Rozental <rogeeff@google.com>:

Update version for CMake and Bazel

PiperOrigin-RevId: 336089889

--
0a36f989acb0e6f7d2f04039c600b0934c44ffed by Abseil Team <absl-team@google.com>:

changes how non-equality is evaluated

absl::c_mismatch is based on std::mismatch, which requires that its
iterators' reference types meet the requirements of
Cpp17EqualityComparable[1]. The previous CL mistakenly wrote
absl::c_mismatch using `*first1 != *first2` which assumes that the
reference types model std::equality_comparable[2] (which was only added
in C++20).

This CL reverts that behaviour.

[0]: http://wg21.link/mismatch
[1]: http://wg21.link/utility.arg.requirements#tab:cpp17.equalitycomparable
[2]: http://wg21.link/concept.equalitycomparable

PiperOrigin-RevId: 335897465

--
7cb902f079838081a15f8b72e0cef46beab653f2 by Derek Mauro <dmauro@google.com>:

Disable a raw_hash_map_allocator.cc test that doesn't build
due to a noexcept bug in gcc 5.4 and 5.5

PiperOrigin-RevId: 335876843
GitOrigin-RevId: 430bda42820b619b346201bc42769d014228e825
Change-Id: I94d5b8e03e0a91d81923aa831f6f63c625e0b836
2020-10-08 11:34:42 -04:00
Abseil Team
887d0eee6b Export of internal Abseil changes
--
d6e582e21ceec768aa72e857c10ba80cad2f2202 by Abseil Team <absl-team@google.com>:

adds bounds-checking for the second range in absl::c_mismatch

The API for the two-range absl::c_mismatch is misleading as it
doesn't check the bounds of the second range against the first one.
This commit cleans up the internals of the overload to make sure that
buggy calls are not exploitable; non-buggy calls are unaffected.

This is consistent with both C++14's two-range std::mismatch and
C++20's std::ranges::mismatch (see http://wg21.link/mismatch).

PiperOrigin-RevId: 335050236
GitOrigin-RevId: d6e582e21ceec768aa72e857c10ba80cad2f2202
Change-Id: I77e0d030adf35c09069ceab5ea67efdf09377390
2020-10-02 22:03:20 -04:00
Abseil Team
093cc27604 Export of internal Abseil changes
--
0674e1ab1c1f71c5362b9e2337333e67f7ed865d by Andy Getzendanner <durandal@google.com>:

btree: fix sign-compare warnings

Import of https://github.com/abseil/abseil-cpp/pull/800

PiperOrigin-RevId: 334668397

--
3b1f289781e4c68e244a7534f95eb0719ca1e8e1 by Abseil Team <absl-team@google.com>:

Avoid iterating past the end of either container in absl::c_transform.

The API for the two-range absl::c_transform is misleading as it
doesn't check the bounds of the second range against the first one.
This commit cleans up the internals of the overload to make sure that
buggy calls are not exploitable; non-buggy calls are unaffected.

This is consistent with C++20 ranges (see
http://wg21.link/alg.transform).

PiperOrigin-RevId: 334629614

--
1184d9c2e7031860638b709c489cbd1b0d861040 by Abseil Team <absl-team@google.com>:

Avoid iterating past the end of either container in absl::c_swap_ranges.

The API for absl::c_swap_ranges is misleading as it doesn't check the
bounds of the second range against the first one. This commit cleans
up the internals of the overload to make sure that buggy calls are not
exploitable; non-buggy calls are unaffected.

This is consistent with C++20 ranges (see http://wg21.link/alg.swap).

PiperOrigin-RevId: 334618454
GitOrigin-RevId: 0674e1ab1c1f71c5362b9e2337333e67f7ed865d
Change-Id: Ifac0e99b1209bb7589bf74215b1d354dd30eabaa
2020-10-01 01:43:11 +00:00
Abseil Team
ab3552a189 Export of internal Abseil changes
--
f13697e3d33803f9667d124072da4f6dd8bfbf85 by Andy Soffer <asoffer@google.com>:

Addressing https://github.com/abseil/abseil-cpp/issues/314, fixing
CMakeLists.txt to reference ABSL_TEST_COPTS rather than ABSL_DEFAULT_COPTS.

ABSL_TEST_COPTS should be preferred for all tests so that they are configured consistently (moreover, CMake should agree with Bazel).

PiperOrigin-RevId: 274932312

--
c31c24a1fa6bb98136adf51ef37c0818ac366690 by Derek Mauro <dmauro@google.com>:

Silence MSAN in the stack consumption test utility

PiperOrigin-RevId: 274912950

--
2412913c05a246cd527cd4c31452f126e9129f3a by CJ Johnson <johnsoncj@google.com>:

Internal change

PiperOrigin-RevId: 274847103

--
75e984a93b5760873501b96ac3229ccfd955daf8 by Abseil Team <absl-team@google.com>:

Reformat BUILD file to current standards.

PiperOrigin-RevId: 274815392

--
a2780e085f1df1e4ca2c814a58c893d1b78a1d9c by Samuel Benzaquen <sbenza@google.com>:

Fix invalid result regarding leading zeros in the exponent.

PiperOrigin-RevId: 274808017

--
dd402e1cb5c4ebacb576372ae24bf289d729d323 by Samuel Benzaquen <sbenza@google.com>:

Make string_view's relational operators constexpr when possible.

PiperOrigin-RevId: 274807873

--
b4ef32565653a5da1cb8bb8d0351586d23519658 by Abseil Team <absl-team@google.com>:

Internal rework.

PiperOrigin-RevId: 274787159

--
70d81971c5914e6785b8e8a9d4f6eb2655dd62c0 by Gennadiy Rozental <rogeeff@google.com>:

Internal rework.

PiperOrigin-RevId: 274715557

--
14f5b0440e353b899cafaaa15b53e77f98f401af by Gennadiy Rozental <rogeeff@google.com>:

Make deprecated statements about ParseFLag/UnparseFlag consistent in a file.

PiperOrigin-RevId: 274668123

--
2e85adbdbb92612e4d750bc34fbca3333128b42d by Abseil Team <absl-team@google.com>:

Allow absl::c_equal to be used with arrays.

This is achieved by allowing container size computation for arrays.

PiperOrigin-RevId: 274426830

--
219719f107226d328773e6cec99fb473f5d3119c by Gennadiy Rozental <rogeeff@google.com>:

Release correct extension interfaces to support usage of absl::Time and absl::Duration as ABSL_FLAG

PiperOrigin-RevId: 274273788

--
47a77f93fda23b69b4a6bdbd506fe643c69a5579 by Gennadiy Rozental <rogeeff@google.com>:

Rework of flags persistence/FlagSaver internals.

PiperOrigin-RevId: 274225213

--
7807be3fe757c19e3b0c487298387683d4c9f5b3 by Abseil Team <absl-team@google.com>:

Switch reference to sdkddkver.h to lowercase, matching conventions used in the Windows SDK and other uses. This helps to avoid confusion on case-sensitive filesystems.

PiperOrigin-RevId: 274061877

--
561304090087a19f1d10f0475f564fe132ebf06e by Andy Getzendanner <durandal@google.com>:

Fix ABSL_WAITER_MODE detection for mingw

Import of https://github.com/abseil/abseil-cpp/pull/342

PiperOrigin-RevId: 274030071

--
9b3caac2cf202b9d440dfa1b4ffd538ac4bf715b by Derek Mauro <dmauro@google.com>:

Support using Abseil with the musl libc implementation.

Only test changes were required:
  * Workaround for a bug in sigaltstack() on musl
  * printf-style pointer formatting (%p) is implementation defined,
    so verify StrFromat produces something compatible
  * Fix detection of feenableexcept()

PiperOrigin-RevId: 274011666

--
73e8a938fc139e1cc8670d4513a445bacc855539 by Abseil Team <absl-team@google.com>:

nvcc workaround: explicitly specify the definition of node_handle::Base

PiperOrigin-RevId: 274011392

--
ab9cc6d042aca7d48e16c504ab10eab39433f4b2 by Andy Soffer <asoffer@google.com>:

Internal change

PiperOrigin-RevId: 273996318

--
e567c4979ca99c7e71821ec1523b8f5edd2c76ac by Abseil Team <absl-team@google.com>:

Introduce a type alias to work around an nvcc bug.

On the previous code, nvcc gets confused thinking that T has to be a parameter
pack, as IsDecomposable accepts one.

PiperOrigin-RevId: 273980472

--
105b6e6339b77a32f4432de05f44cd3f9c436751 by Eric Fiselier <ericwf@google.com>:

Import of CCTZ from GitHub.

PiperOrigin-RevId: 273955589

--
8feb87ff1d7e721fe094855e67c19539d5e582b7 by Abseil Team <absl-team@google.com>:

Avoid dual-exporting scheduling_mode.h

PiperOrigin-RevId: 273825112

--
fbc37854776d295dae98fb9d06a541f296daab95 by Andy Getzendanner <durandal@google.com>:

Fix ABSL_HAVE_ALARM check on mingw

Import of https://github.com/abseil/abseil-cpp/pull/341

PiperOrigin-RevId: 273817839

--
6aedcd63a735b9133e143b043744ba0a25407f6f by Andy Soffer <asoffer@google.com>:

Remove bit_gen_view.h now that all callers have been migrated to bit_gen_ref.h
Tested:
TGP - https://test.corp.google.com/ui#id=OCL:273762409:BASE:273743370:1570639020744:3001bcb5

PiperOrigin-RevId: 273810331

--
6573de24a66ba715c579f7f32b5c48a1d743c7f8 by Abseil Team <absl-team@google.com>:

Internal change.

PiperOrigin-RevId: 273589963

--
91c8c28b6dca26d98b39e8e06a8ed17c701ff793 by Abseil Team <absl-team@google.com>:

Update macro name for `ABSL_GUARDED_BY()` in the example section.

PiperOrigin-RevId: 273286983

--
0ff7d1a93d70f8ecd693f8dbb98b7a4a016ca2a4 by Abseil Team <absl-team@google.com>:

Fix potential integer overflow in the absl time library.

In absl::FromTM, the tm.tm_year is added by 1900 regarding that tm.tm_year represents the years since 1900. This change checks integer overflow before doing the arithmetic operation.

PiperOrigin-RevId: 273092952

--
b41c2a1310086807be09a833099ae6d4009f037c by Gennadiy Rozental <rogeeff@google.com>:

Correctly Unlock the global mutex in case of concurrent flag initialization.

Fixes #386

PiperOrigin-RevId: 272979749

--
c53103e71b2a6063af3c6d4ff68aa2d8f9ae9e06 by Abseil Team <absl-team@google.com>:

Try to become idle only when there is no wakeup.

Immediately after waking up (when futex wait returns), the current thread tries
to become idle doing bunch of memory loads and a branch.  Problem is that there
is a good chance that we woke up due to a wakeup, especially for actively used
threads.  For such wakeups, calling MaybeBecomeIdle() would be a waste of
cycles.

Instead, call MaybeBecomeIdle() only when we are sure there is no wakeup.  For
idle threads the net effect should be the same.  For active, threads this will
be more efficient.

Moreover, since MaybeBecomeIdle() is called before waiting on the futex, the
current thread will try to become idle before sleeping.  This should result
in more accurate idleness and more efficient release of thread resources.

PiperOrigin-RevId: 272940381
GitOrigin-RevId: f13697e3d33803f9667d124072da4f6dd8bfbf85
Change-Id: I36de05aec12595183725652dd362dfa58fb095d0
2019-10-16 10:42:51 -04:00
Abseil Team
72e09a54d9 Export of internal Abseil changes.
--
2ee5dbb79b56539b580c3a36eec5a025d08b7022 by Eric Fiselier <ericwf@google.com>:

Unconditionally apply no-sanitize attributes.

We currently fail to apply the attributes in open-source
land because the build system doesn't define ADDRESS_SANITIZER
like we expect.

The attributes should have no effect when the sanitizers are
disabled.

PiperOrigin-RevId: 255024122

--
5a123175146de14d04013862aa378f28f8eff73c by CJ Johnson <johnsoncj@google.com>:

Updates the InputIterator-accepting member functions of InlinedVector to be cleaner/easier to read

PiperOrigin-RevId: 254994794

--
a4bdb61407a76317810785a34e49f996699ab4a4 by Abseil Team <absl-team@google.com>:

Added back c_move_backward which was previously deleted by mistake.

PiperOrigin-RevId: 254990809

--
bc427ca5f7fb88a70ba3a676bb9c7ff829c65ae9 by CJ Johnson <johnsoncj@google.com>:

Removes DestroyAndDeallocate() function from the internal details of InlinedVector because it ended up not being particularly useful

PiperOrigin-RevId: 254981201
GitOrigin-RevId: 2ee5dbb79b56539b580c3a36eec5a025d08b7022
Change-Id: I825c6c0a2fcf13ed6e60d71224037a57d7068d55
2019-06-25 16:21:15 -04:00
nik7273
38b704384c Changed HTTP URLs to HTTPS where possible (#270) 2019-03-08 10:27:53 -05:00
Abseil Team
02451914b9 Export of internal Abseil changes.
--
74c1330e29f1501f2738258faf9ec4564395c90a by Gennadiy Civil <misterg@google.com>:

Merging https://github.com/abseil/abseil-cpp/pull/166

PiperOrigin-RevId: 212487256

--
4ac236574ff8fb3cc1125505292b0bd8c8192da9 by Abseil Team <absl-team@google.com>:

Allow c_move to take rvalue containers.

PiperOrigin-RevId: 212458618

--
ce94e23984870db666d4c91623ae45b3c60b5b61 by Matt Armstrong <marmstrong@google.com>:

Internal change.

PiperOrigin-RevId: 212153041

--
7d88d286821c5839934756dd63a704ed162c49cb by Chris Kennelly <ckennelly@google.com>:

Internal change

PiperOrigin-RevId: 211982309

--
ddae814b3f609948c20551ea3d80bf51b973f480 by Abseil Team <absl-team@google.com>:

Remove unused argument from InlinedVector's AllocatorAndTag

This is not part of InlinedVector's public interface.

PiperOrigin-RevId: 211973017

--
051fbfd81648a8da66c62c6603af63038d709c15 by Abseil Team <absl-team@google.com>:

Minor performance fix

PiperOrigin-RevId: 211820453

--
c205cb2add7400bc8caf2131cb700eea560b7dbf by Laramie Leavitt <lar@google.com>:

Make absl::Span a tiny bit more consistent.

Add constexper to equivalent absl::Span members as described by
http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0122r7.pdf

* Span constructor use consistently delegate to Span(ptr, length)
* Mark more member methods as constexpr.
* Use data() and size() consistently in member methods.

PiperOrigin-RevId: 211707244

--
55500c9e941f2f58f4a95c121f32772408866eee by Derek Mauro <dmauro@google.com>:

Stop catching polymorphic exception types by value.
GCC 8 emits a warning for this.

PiperOrigin-RevId: 211684466
GitOrigin-RevId: 74c1330e29f1501f2738258faf9ec4564395c90a
Change-Id: Iceab4a5b30ee35d82ef494830262ad29c028cb0a
2018-09-11 14:28:55 -04:00
Abseil Team
eb5bbdda6c Changes imported from Abseil "staging" branch:
- 5923451fb3b082e8bedb800cb676378b0f52d651 Remove internal-only deprecated APIs. by Daniel Katz <katzdm@google.com>
  - c715bf6e5533a9a5d827e806ccd6e8ee68ad2a53 Small fix for comment in span.h by Abseil Team <absl-team@google.com>
  - ef89cc8dac0631b4ad3499d1f0883670b43567df Rename an internal detail to de-conflict with a badly-nam... by Abseil Team <absl-team@google.com>
  - b53761a945ffdab39d5340904ca822571672f11a Remove base/internal/log_severity.cc, which is omitted fr... by Abseil Team <absl-team@google.com>
  - 56685b1852840d3838e24d83849d56644949e9b7 Reimplementing MallocHook such that the C API wraps the C... by Abseil Team <absl-team@google.com>

GitOrigin-RevId: 5923451fb3b082e8bedb800cb676378b0f52d651
Change-Id: I9b854d46b57990c9a10971391d762b280488bcee
2017-12-28 15:09:55 -05:00
misterg
c2e7548296 Initial Commit 2017-09-19 16:54:40 -04:00