Stop using C++17 type traits polyfills

This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 894202105
Change-Id: I57bb2a1647be1fedf9b724a07042fd0f564ce074
This commit is contained in:
Abseil Team
2026-04-03 12:33:17 -07:00
committed by Copybara-Service
parent 3eb0f0bd73
commit ed2114e8ff
67 changed files with 352 additions and 346 deletions

View File

@@ -1758,7 +1758,7 @@ ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 void c_iota(Sequence& sequence,
// accumulation by value.
//
// Note: Due to a language technicality this function has return type
// absl::decay_t<T>. As a user of this function you can casually read
// std::decay_t<T>. As a user of this function you can casually read
// this as "returns T by value" and assume it does the right thing.
template <typename Sequence, typename T>
ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 decay_t<T> c_accumulate(
@@ -1785,7 +1785,7 @@ ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 decay_t<T> c_accumulate(
// to compute the cumulative inner product of container element pairs.
//
// Note: Due to a language technicality this function has return type
// absl::decay_t<T>. As a user of this function you can casually read
// std::decay_t<T>. As a user of this function you can casually read
// this as "returns T by value" and assume it does the right thing.
template <typename Sequence1, typename Sequence2, typename T>
ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 decay_t<T> c_inner_product(

View File

@@ -945,8 +945,8 @@ TEST(ThrowingValueTraitsTest, RelationalOperators) {
}
TEST(ThrowingAllocatorTraitsTest, Assignablility) {
EXPECT_TRUE(absl::is_move_assignable<ThrowingAllocator<int>>::value);
EXPECT_TRUE(absl::is_copy_assignable<ThrowingAllocator<int>>::value);
EXPECT_TRUE(std::is_move_assignable<ThrowingAllocator<int>>::value);
EXPECT_TRUE(std::is_copy_assignable<ThrowingAllocator<int>>::value);
EXPECT_TRUE(std::is_nothrow_move_assignable<ThrowingAllocator<int>>::value);
EXPECT_TRUE(std::is_nothrow_copy_assignable<ThrowingAllocator<int>>::value);
}

View File

@@ -44,22 +44,22 @@ enum class TypeSpec;
enum class AllocSpec;
constexpr TypeSpec operator|(TypeSpec a, TypeSpec b) {
using T = absl::underlying_type_t<TypeSpec>;
using T = std::underlying_type_t<TypeSpec>;
return static_cast<TypeSpec>(static_cast<T>(a) | static_cast<T>(b));
}
constexpr TypeSpec operator&(TypeSpec a, TypeSpec b) {
using T = absl::underlying_type_t<TypeSpec>;
using T = std::underlying_type_t<TypeSpec>;
return static_cast<TypeSpec>(static_cast<T>(a) & static_cast<T>(b));
}
constexpr AllocSpec operator|(AllocSpec a, AllocSpec b) {
using T = absl::underlying_type_t<AllocSpec>;
using T = std::underlying_type_t<AllocSpec>;
return static_cast<AllocSpec>(static_cast<T>(a) | static_cast<T>(b));
}
constexpr AllocSpec operator&(AllocSpec a, AllocSpec b) {
using T = absl::underlying_type_t<AllocSpec>;
using T = std::underlying_type_t<AllocSpec>;
return static_cast<AllocSpec>(static_cast<T>(a) & static_cast<T>(b));
}
@@ -842,7 +842,7 @@ class DefaultFactory {
template <size_t LazyContractsCount, typename LazyFactory,
typename LazyOperation>
using EnableIfTestable = typename absl::enable_if_t<
using EnableIfTestable = typename std::enable_if_t<
LazyContractsCount != 0 &&
!std::is_same<LazyFactory, UninitializedT>::value &&
!std::is_same<LazyOperation, UninitializedT>::value>;
@@ -994,7 +994,7 @@ class ExceptionSafetyTestBuilder {
* method tester.WithInitialValue(...).
*/
template <typename NewFactory>
ExceptionSafetyTestBuilder<absl::decay_t<NewFactory>, Operation, Contracts...>
ExceptionSafetyTestBuilder<std::decay_t<NewFactory>, Operation, Contracts...>
WithFactory(const NewFactory& new_factory) const {
return {new_factory, operation_, contracts_};
}
@@ -1005,7 +1005,7 @@ class ExceptionSafetyTestBuilder {
* newly created tester.
*/
template <typename NewOperation>
ExceptionSafetyTestBuilder<Factory, absl::decay_t<NewOperation>, Contracts...>
ExceptionSafetyTestBuilder<Factory, std::decay_t<NewOperation>, Contracts...>
WithOperation(const NewOperation& new_operation) const {
return {factory_, new_operation, contracts_};
}
@@ -1025,11 +1025,11 @@ class ExceptionSafetyTestBuilder {
*/
template <typename... MoreContracts>
ExceptionSafetyTestBuilder<Factory, Operation, Contracts...,
absl::decay_t<MoreContracts>...>
std::decay_t<MoreContracts>...>
WithContracts(const MoreContracts&... more_contracts) const {
return {
factory_, operation_,
std::tuple_cat(contracts_, std::tuple<absl::decay_t<MoreContracts>...>(
std::tuple_cat(contracts_, std::tuple<std::decay_t<MoreContracts>...>(
more_contracts...))};
}

View File

@@ -96,7 +96,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED FixedArray {
absl::allocator_is_nothrow<allocator_type>::value;
}
static constexpr bool DefaultConstructorIsNonTrivial() {
return !absl::is_trivially_default_constructible<StorageElement>::value;
return !std::is_trivially_default_constructible<StorageElement>::value;
}
public:
@@ -414,14 +414,14 @@ class ABSL_ATTRIBUTE_WARN_UNUSED FixedArray {
// error: call to int __builtin___sprintf_chk(etc...)
// will always overflow destination buffer [-Werror]
//
template <typename OuterT, typename InnerT = absl::remove_extent_t<OuterT>,
template <typename OuterT, typename InnerT = std::remove_extent_t<OuterT>,
size_t InnerN = std::extent<OuterT>::value>
struct StorageElementWrapper {
InnerT array[InnerN];
};
using StorageElement =
absl::conditional_t<std::is_array<value_type>::value,
std::conditional_t<std::is_array<value_type>::value,
StorageElementWrapper<value_type>, value_type>;
static pointer AsValueType(pointer ptr) { return ptr; }
@@ -458,7 +458,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED FixedArray {
};
using InlinedStorage =
absl::conditional_t<inline_elements == 0, EmptyInlinedStorage,
std::conditional_t<inline_elements == 0, EmptyInlinedStorage,
NonEmptyInlinedStorage>;
// Storage

View File

@@ -192,7 +192,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED InlinedVector {
// allocator doesn't do anything fancy, and there is nothing on the heap
// then we know it is legal for us to simply memcpy the other vector's
// inlined bytes to form our copy of its elements.
if (absl::is_trivially_copy_constructible<value_type>::value &&
if (std::is_trivially_copy_constructible<value_type>::value &&
std::is_same<A, std::allocator<value_type>>::value &&
!other.storage_.GetIsAllocated()) {
storage_.MemcpyFrom(other.storage_);
@@ -857,7 +857,7 @@ class ABSL_ATTRIBUTE_WARN_UNUSED InlinedVector {
// Assumption check: we shouldn't be told to use memcpy to implement move
// assignment unless we have trivially destructible elements and an
// allocator that does nothing fancy.
static_assert(absl::is_trivially_destructible<value_type>::value, "");
static_assert(std::is_trivially_destructible<value_type>::value, "");
static_assert(std::is_same<A, std::allocator<value_type>>::value, "");
// Throw away our existing heap allocation, if any. There is no need to

View File

@@ -231,7 +231,7 @@ struct key_compare_adapter {
explicit operator Compare() const { return comp(); }
template <typename T, typename U,
absl::enable_if_t<
std::enable_if_t<
std::is_same<bool, compare_result_t<Compare, T, U>>::value,
int> = 0>
bool operator()(const T &lhs, const U &rhs) const {
@@ -247,7 +247,7 @@ struct key_compare_adapter {
template <
typename T, typename U,
absl::enable_if_t<std::is_convertible<compare_result_t<Compare, T, U>,
std::enable_if_t<std::is_convertible<compare_result_t<Compare, T, U>,
absl::weak_ordering>::value,
int> = 0>
absl::weak_ordering operator()(const T &lhs, const U &rhs) const {
@@ -270,7 +270,7 @@ struct key_compare_adapter {
return lhs_comp_rhs;
}
};
using type = absl::conditional_t<
using type = std::conditional_t<
std::is_base_of<BtreeTestOnlyCheckedCompareOptOutBase, Compare>::value,
Compare, checked_compare>;
};
@@ -377,7 +377,7 @@ struct common_params : common_policy_traits<SlotPolicy> {
// this, then there will be cascading compilation failures that are confusing
// for users.
using key_compare =
absl::conditional_t<!compare_has_valid_result_type<Compare, Key>(),
std::conditional_t<!compare_has_valid_result_type<Compare, Key>(),
Compare,
typename key_compare_adapter<Compare, Key>::type>;
@@ -406,7 +406,7 @@ struct common_params : common_policy_traits<SlotPolicy> {
using const_reference = const value_type &;
using value_compare =
absl::conditional_t<IsMap,
std::conditional_t<IsMap,
map_value_compare<original_key_compare, value_type>,
original_key_compare>;
using is_map_container = std::integral_constant<bool, IsMap>;
@@ -438,7 +438,7 @@ struct common_params : common_policy_traits<SlotPolicy> {
// This is an integral type large enough to hold as many slots as will fit a
// node of TargetNodeSize bytes.
using node_count_type =
absl::conditional_t<(kNodeSlotSpace / sizeof(slot_type) >
std::conditional_t<(kNodeSlotSpace / sizeof(slot_type) >
(std::numeric_limits<uint8_t>::max)()),
uint16_t, uint8_t>; // NOLINT
};
@@ -1119,7 +1119,7 @@ class btree_iterator : private btree_iterator_generation_info {
using slot_type = typename params_type::slot_type;
// In sets, all iterators are const.
using iterator = absl::conditional_t<
using iterator = std::conditional_t<
is_map_container::value,
btree_iterator<normal_node, normal_reference, normal_pointer>,
btree_iterator<normal_node, const_reference, const_pointer>>;
@@ -1146,7 +1146,7 @@ class btree_iterator : private btree_iterator_generation_info {
// const_iterator, but it specifically avoids hiding the copy constructor so
// that the trivial one will be used when possible.
template <typename N, typename R, typename P,
absl::enable_if_t<
std::enable_if_t<
std::is_same<btree_iterator<N, R, P>, iterator>::value &&
std::is_same<btree_iterator, const_iterator>::value,
int> = 0>
@@ -1252,7 +1252,7 @@ class btree_iterator : private btree_iterator_generation_info {
// NOTE: the const_cast is safe because this constructor is only called by
// non-const methods and the container owns the nodes.
template <typename N, typename R, typename P,
absl::enable_if_t<
std::enable_if_t<
std::is_same<btree_iterator<N, R, P>, const_iterator>::value &&
std::is_same<btree_iterator, iterator>::value,
int> = 0>

View File

@@ -412,8 +412,8 @@ class btree_set_container : public btree_container<Tree> {
// `this`, it is left unmodified in `src`.
template <
typename T,
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_same<value_type, typename T::value_type>,
std::is_same<allocator_type, typename T::allocator_type>,
std::is_same<typename params_type::is_map_container,
@@ -431,8 +431,8 @@ class btree_set_container : public btree_container<Tree> {
template <
typename T,
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_same<value_type, typename T::value_type>,
std::is_same<allocator_type, typename T::allocator_type>,
std::is_same<typename params_type::is_map_container,
@@ -474,7 +474,7 @@ class btree_map_container : public btree_set_container<Tree> {
typename Tree::params_type::mapped_type, M>>;
template <class K, bool KValue, class M, bool MValue, typename... Dummy>
using LifetimeBoundKV =
absl::conjunction<LifetimeBoundK<K, KValue, absl::void_t<Dummy...>>,
std::conjunction<LifetimeBoundK<K, KValue, absl::void_t<Dummy...>>,
LifetimeBoundV<M, MValue>>;
public:
@@ -824,8 +824,8 @@ class btree_multiset_container : public btree_container<Tree> {
// Moves all elements from `src` into `this`.
template <
typename T,
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_same<value_type, typename T::value_type>,
std::is_same<allocator_type, typename T::allocator_type>,
std::is_same<typename params_type::is_map_container,
@@ -840,8 +840,8 @@ class btree_multiset_container : public btree_container<Tree> {
template <
typename T,
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_same<value_type, typename T::value_type>,
std::is_same<allocator_type, typename T::allocator_type>,
std::is_same<typename params_type::is_map_container,

View File

@@ -58,7 +58,7 @@ template <class Cond>
using EnableIf = std::enable_if_t<Cond::value, int>;
template <bool Value, class T>
using HasValue = std::conditional_t<Value, T, absl::negation<T>>;
using HasValue = std::conditional_t<Value, T, std::negation<T>>;
template <class T>
struct IfRRef {

View File

@@ -81,7 +81,7 @@ struct common_policy_traits {
// Note: we use remove_const_t so that the two overloads have different args
// in the case of sets with explicitly const value_types.
template <class P = Policy>
static auto element(absl::remove_const_t<slot_type>* slot)
static auto element(std::remove_const_t<slot_type>* slot)
-> decltype(P::element(slot)) {
return P::element(slot);
}

View File

@@ -166,7 +166,7 @@ struct TupleMoveConstructible : std::false_type {};
template <class... Ts, class... Vs>
struct TupleMoveConstructible<true, CompressedTuple<Ts...>, Vs...>
: std::integral_constant<
bool, absl::conjunction<
bool, std::conjunction<
TupleElementMoveConstructible<Ts, Vs&&>...>::value> {};
template <typename T>
@@ -227,11 +227,11 @@ class ABSL_INTERNAL_COMPRESSED_TUPLE_DECLSPEC CompressedTuple
: CompressedTuple::CompressedTupleImpl(absl::in_place, base...) {}
template <typename First, typename... Vs,
absl::enable_if_t<
absl::conjunction<
std::enable_if_t<
std::conjunction<
// Ensure we are not hiding default copy/move constructors.
absl::negation<std::is_same<void(CompressedTuple),
void(absl::decay_t<First>)>>,
std::negation<std::is_same<void(CompressedTuple),
void(std::decay_t<First>)>>,
internal_compressed_tuple::TupleItemsMoveConstructible<
CompressedTuple<Ts...>, First, Vs...>>::value,
bool> = true>

View File

@@ -350,11 +350,11 @@ union map_slot_type {
~map_slot_type() = delete;
using value_type = std::pair<const K, V>;
using mutable_value_type =
std::pair<absl::remove_const_t<K>, absl::remove_const_t<V>>;
std::pair<std::remove_const_t<K>, std::remove_const_t<V>>;
value_type value;
mutable_value_type mutable_value;
absl::remove_const_t<K> key;
std::remove_const_t<K> key;
};
template <class K, class V>
@@ -362,7 +362,7 @@ struct map_slot_policy {
using slot_type = map_slot_type<K, V>;
using value_type = std::pair<const K, V>;
using mutable_value_type =
std::pair<absl::remove_const_t<K>, absl::remove_const_t<V>>;
std::pair<std::remove_const_t<K>, std::remove_const_t<V>>;
private:
static void emplace(slot_type* slot) {

View File

@@ -38,7 +38,7 @@ struct hash_policy_traits : common_policy_traits<Policy> {
private:
struct ReturnKey {
template <class Key,
absl::enable_if_t<std::is_lvalue_reference<Key>::value, int> = 0>
std::enable_if_t<std::is_lvalue_reference<Key>::value, int> = 0>
static key_type& Impl(Key&& k, int) {
return *std::launder(
const_cast<key_type*>(std::addressof(std::forward<Key>(k))));

View File

@@ -79,7 +79,7 @@ using IsSwapOk = absl::type_traits_internal::IsSwappable<ValueType<A>>;
template <typename A,
bool IsTriviallyDestructible =
absl::is_trivially_destructible<ValueType<A>>::value &&
std::is_trivially_destructible<ValueType<A>>::value &&
std::is_same<A, std::allocator<ValueType<A>>>::value>
struct DestroyAdapter;
@@ -288,14 +288,14 @@ class Storage {
struct ElementwiseSwapPolicy {};
struct ElementwiseConstructPolicy {};
using MoveAssignmentPolicy = absl::conditional_t<
using MoveAssignmentPolicy = std::conditional_t<
// Fast path: if the value type can be trivially move assigned and
// destroyed, and we know the allocator doesn't do anything fancy, then
// it's safe for us to simply adopt the contents of the storage for
// `other` and remove its own reference to them. It's as if we had
// individually move-assigned each value and then destroyed the original.
absl::conjunction<absl::is_trivially_move_assignable<ValueType<A>>,
absl::is_trivially_destructible<ValueType<A>>,
std::conjunction<std::is_trivially_move_assignable<ValueType<A>>,
std::is_trivially_destructible<ValueType<A>>,
std::is_same<A, std::allocator<ValueType<A>>>>::value,
MemcpyPolicy,
// Otherwise we use move assignment if possible. If not, we simulate
@@ -304,21 +304,21 @@ class Storage {
// Note that this is in contrast to e.g. std::vector and std::optional,
// which are themselves not move-assignable when their contained type is
// not.
absl::conditional_t<IsMoveAssignOk<A>::value, ElementwiseAssignPolicy,
std::conditional_t<IsMoveAssignOk<A>::value, ElementwiseAssignPolicy,
ElementwiseConstructPolicy>>;
// The policy to be used specifically when swapping inlined elements.
using SwapInlinedElementsPolicy = absl::conditional_t<
using SwapInlinedElementsPolicy = std::conditional_t<
// Fast path: if the value type can be trivially relocated, and we
// know the allocator doesn't do anything fancy, then it's safe for us
// to simply swap the bytes in the inline storage. It's as if we had
// relocated the first vector's elements into temporary storage,
// relocated the second's elements into the (now-empty) first's,
// and then relocated from temporary storage into the second.
absl::conjunction<absl::is_trivially_relocatable<ValueType<A>>,
std::conjunction<absl::is_trivially_relocatable<ValueType<A>>,
std::is_same<A, std::allocator<ValueType<A>>>>::value,
MemcpyPolicy,
absl::conditional_t<IsSwapOk<A>::value, ElementwiseSwapPolicy,
std::conditional_t<IsSwapOk<A>::value, ElementwiseSwapPolicy,
ElementwiseConstructPolicy>>;
static SizeType<A> NextCapacity(SizeType<A> current_capacity) {
@@ -348,7 +348,7 @@ class Storage {
// Fast path: if no destructors need to be run and we know the allocator
// doesn't do anything fancy, then all we need to do is deallocate (and
// maybe not even that).
if (absl::is_trivially_destructible<ValueType<A>>::value &&
if (std::is_trivially_destructible<ValueType<A>>::value &&
std::is_same<A, std::allocator<ValueType<A>>>::value) {
DeallocateIfAllocated();
return;
@@ -507,11 +507,11 @@ class Storage {
// First case above
absl::is_trivially_relocatable<V>::value ||
// Second case above
(absl::is_trivially_move_assignable<V>::value &&
absl::is_trivially_destructible<V>::value) ||
(std::is_trivially_move_assignable<V>::value &&
std::is_trivially_destructible<V>::value) ||
// Third case above
(absl::is_trivially_copy_constructible<V>::value ||
absl::is_trivially_copy_assignable<V>::value))));
(std::is_trivially_copy_constructible<V>::value ||
std::is_trivially_copy_assignable<V>::value))));
}
GetSizeAndIsAllocated() = other_storage.GetSizeAndIsAllocated();
@@ -596,7 +596,7 @@ void Storage<T, N, A>::InitFrom(const Storage& other) {
// Fast path: if the value type is trivially copy constructible and we know
// the allocator doesn't do anything fancy, then we know it is legal for us to
// simply memcpy the other vector's elements.
if (absl::is_trivially_copy_constructible<ValueType<A>>::value &&
if (std::is_trivially_copy_constructible<ValueType<A>>::value &&
std::is_same<A, std::allocator<ValueType<A>>>::value) {
std::memcpy(reinterpret_cast<char*>(dst),
reinterpret_cast<const char*>(src), n * sizeof(ValueType<A>));

View File

@@ -261,7 +261,7 @@ struct AlignOf<Aligned<T, N>> {
// Does `Ts...` contain `T`?
template <class T, class... Ts>
using Contains = absl::disjunction<std::is_same<T, Ts>...>;
using Contains = std::disjunction<std::is_same<T, Ts>...>;
template <class From, class To>
using CopyConst =
@@ -352,7 +352,7 @@ class LayoutImpl<
absl::index_sequence<OffsetSeq...>> {
private:
static_assert(sizeof...(Elements) > 0, "At least one field is required");
static_assert(absl::conjunction<IsLegalElementType<Elements>...>::value,
static_assert(std::conjunction<IsLegalElementType<Elements>...>::value,
"Invalid element type (see IsLegalElementType)");
static_assert(sizeof...(StaticSizeSeq) <= sizeof...(Elements),
"Too many static sizes specified");

View File

@@ -88,7 +88,7 @@ class raw_hash_map : public raw_hash_set<Policy, Params...> {
typename Policy::mapped_type, V>>;
template <class K, bool KValue, class V, bool VValue, typename... Dummy>
using LifetimeBoundKV =
absl::conjunction<LifetimeBoundK<K, KValue, absl::void_t<Dummy...>>,
std::conjunction<LifetimeBoundK<K, KValue, absl::void_t<Dummy...>>,
LifetimeBoundV<V, VValue>>;
public:

View File

@@ -1930,7 +1930,7 @@ class raw_hash_set {
// An enabler for insert(T&&): T must be convertible to init_type or be the
// same as [cv] value_type [ref].
template <class T>
using Insertable = absl::disjunction<
using Insertable = std::disjunction<
std::is_same<absl::remove_cvref_t<reference>, absl::remove_cvref_t<T>>,
std::is_convertible<T, init_type>>;
template <class T>
@@ -1970,9 +1970,9 @@ class raw_hash_set {
using iterator_category = std::forward_iterator_tag;
using value_type = typename raw_hash_set::value_type;
using reference =
absl::conditional_t<PolicyTraits::constant_iterators::value,
std::conditional_t<PolicyTraits::constant_iterators::value,
const value_type&, value_type&>;
using pointer = absl::remove_reference_t<reference>*;
using pointer = std::remove_reference_t<reference>*;
using difference_type = typename raw_hash_set::difference_type;
iterator() {}

View File

@@ -608,7 +608,7 @@ class FlagImpl final : public CommandLineFlag {
*value = ReadOneBool();
}
template <typename T,
absl::enable_if_t<flags_internal::StorageKind<T>() ==
std::enable_if_t<flags_internal::StorageKind<T>() ==
FlagValueStorageKind::kOneWordAtomic,
int> = 0>
void Read(T* value) const ABSL_LOCKS_EXCLUDED(DataGuard()) {

View File

@@ -191,7 +191,7 @@ class ABSL_NULLABILITY_COMPATIBLE ABSL_ATTRIBUTE_OWNER AnyInvocable
// Upon construction, `*this` is only empty if `f` is a function pointer or
// member pointer type and is null, or if `f` is an `AnyInvocable` that is
// empty.
template <class F, typename = absl::enable_if_t<
template <class F, typename = std::enable_if_t<
internal_any_invocable::CanConvert<Sig, F>::value>>
AnyInvocable(F&& f) // NOLINT
: Impl(internal_any_invocable::ConversionConstruct(),
@@ -206,25 +206,25 @@ class ABSL_NULLABILITY_COMPATIBLE ABSL_ATTRIBUTE_OWNER AnyInvocable
// absl::in_place_type<PossiblyImmovableType>, arg1, arg2);
//
template <class T, class... Args,
typename = absl::enable_if_t<
typename = std::enable_if_t<
internal_any_invocable::CanEmplace<Sig, T, Args...>::value>>
explicit AnyInvocable(absl::in_place_type_t<T>, Args&&... args)
: Impl(absl::in_place_type<absl::decay_t<T>>,
: Impl(absl::in_place_type<std::decay_t<T>>,
std::forward<Args>(args)...) {
static_assert(std::is_same<T, absl::decay_t<T>>::value,
static_assert(std::is_same<T, std::decay_t<T>>::value,
"The explicit template argument of in_place_type is required "
"to be an unqualified object type.");
}
// Overload of the above constructor to support list-initialization.
template <class T, class U, class... Args,
typename = absl::enable_if_t<internal_any_invocable::CanEmplace<
typename = std::enable_if_t<internal_any_invocable::CanEmplace<
Sig, T, std::initializer_list<U>&, Args...>::value>>
explicit AnyInvocable(absl::in_place_type_t<T>,
std::initializer_list<U> ilist, Args&&... args)
: Impl(absl::in_place_type<absl::decay_t<T>>, ilist,
: Impl(absl::in_place_type<std::decay_t<T>>, ilist,
std::forward<Args>(args)...) {
static_assert(std::is_same<T, absl::decay_t<T>>::value,
static_assert(std::is_same<T, std::decay_t<T>>::value,
"The explicit template argument of in_place_type is required "
"to be an unqualified object type.");
}
@@ -248,7 +248,7 @@ class ABSL_NULLABILITY_COMPATIBLE ABSL_ATTRIBUTE_OWNER AnyInvocable
// Upon assignment, `*this` is only empty if `f` is a function pointer or
// member pointer type and is null, or if `f` is an `AnyInvocable` that is
// empty.
template <class F, typename = absl::enable_if_t<
template <class F, typename = std::enable_if_t<
internal_any_invocable::CanAssign<Sig, F>::value>>
AnyInvocable& operator=(F&& f) {
*this = AnyInvocable(std::forward<F>(f));
@@ -260,7 +260,7 @@ class ABSL_NULLABILITY_COMPATIBLE ABSL_ATTRIBUTE_OWNER AnyInvocable
// `AnyInvocable` instance.
template <
class F,
typename = absl::enable_if_t<
typename = std::enable_if_t<
internal_any_invocable::CanAssignReferenceWrapper<Sig, F>::value>>
AnyInvocable& operator=(std::reference_wrapper<F> f) noexcept {
*this = AnyInvocable(f);

View File

@@ -41,7 +41,7 @@ struct _ {};
template <class T>
struct Wrapper {
template <class U,
class = absl::enable_if_t<std::is_convertible<U, T>::value>>
class = std::enable_if_t<std::is_convertible<U, T>::value>>
Wrapper(U&&); // NOLINT
};
@@ -58,7 +58,7 @@ template <class Qualifiers, class This>
struct QualifiersForThisImpl {
static_assert(std::is_object<This>::value, "");
using type =
absl::conditional_t<std::is_const<Qualifiers>::value, const This, This>&;
std::conditional_t<std::is_const<Qualifiers>::value, const This, This>&;
};
template <class Qualifiers, class This>
@@ -69,7 +69,7 @@ template <class Qualifiers, class This>
struct QualifiersForThisImpl<Qualifiers&&, This> {
static_assert(std::is_object<This>::value, "");
using type =
absl::conditional_t<std::is_const<Qualifiers>::value, const This, This>&&;
std::conditional_t<std::is_const<Qualifiers>::value, const This, This>&&;
};
template <class Qualifiers, class This>
@@ -84,38 +84,38 @@ struct GiveQualifiersToFunImpl;
template <class T, class R, class... P>
struct GiveQualifiersToFunImpl<T, R(P...)> {
using type =
absl::conditional_t<std::is_const<T>::value, R(P...) const, R(P...)>;
std::conditional_t<std::is_const<T>::value, R(P...) const, R(P...)>;
};
template <class T, class R, class... P>
struct GiveQualifiersToFunImpl<T&, R(P...)> {
using type =
absl::conditional_t<std::is_const<T>::value, R(P...) const&, R(P...)&>;
std::conditional_t<std::is_const<T>::value, R(P...) const&, R(P...)&>;
};
template <class T, class R, class... P>
struct GiveQualifiersToFunImpl<T&&, R(P...)> {
using type =
absl::conditional_t<std::is_const<T>::value, R(P...) const&&, R(P...) &&>;
std::conditional_t<std::is_const<T>::value, R(P...) const&&, R(P...) &&>;
};
template <class T, class R, class... P>
struct GiveQualifiersToFunImpl<T, R(P...) noexcept> {
using type = absl::conditional_t<std::is_const<T>::value,
using type = std::conditional_t<std::is_const<T>::value,
R(P...) const noexcept, R(P...) noexcept>;
};
template <class T, class R, class... P>
struct GiveQualifiersToFunImpl<T&, R(P...) noexcept> {
using type =
absl::conditional_t<std::is_const<T>::value, R(P...) const & noexcept,
std::conditional_t<std::is_const<T>::value, R(P...) const & noexcept,
R(P...) & noexcept>;
};
template <class T, class R, class... P>
struct GiveQualifiersToFunImpl<T&&, R(P...) noexcept> {
using type =
absl::conditional_t<std::is_const<T>::value, R(P...) const && noexcept,
std::conditional_t<std::is_const<T>::value, R(P...) const && noexcept,
R(P...) && noexcept>;
};
@@ -367,14 +367,14 @@ struct TestParams {
}
using CompatibleAnyInvocableFunType =
absl::conditional_t<std::is_rvalue_reference<Qual>::value,
std::conditional_t<std::is_rvalue_reference<Qual>::value,
GiveQualifiersToFun<const _&&, UnqualifiedFunType>,
GiveQualifiersToFun<const _&, UnqualifiedFunType>>;
using CompatibleAnyInvType = AnyInvocable<CompatibleAnyInvocableFunType>;
using IncompatibleInvocable =
absl::conditional_t<std::is_rvalue_reference<Qual>::value,
std::conditional_t<std::is_rvalue_reference<Qual>::value,
GiveQualifiersToFun<_&, UnqualifiedFunType>(_::*),
GiveQualifiersToFun<_&&, UnqualifiedFunType>(_::*)>;
};
@@ -1284,7 +1284,7 @@ TYPED_TEST_P(AnyInvTestNonRvalue, NonMoveableResultType) {
// Just like plain functors, it should work fine to use an AnyInvocable that
// returns the non-moveable type.
using UnqualifiedFun =
absl::conditional_t<TypeParam::kIsNoexcept, Result() noexcept, Result()>;
std::conditional_t<TypeParam::kIsNoexcept, Result() noexcept, Result()>;
using Fun =
GiveQualifiersToFun<typename TypeParam::Qualifiers, UnqualifiedFun>;
@@ -1364,7 +1364,7 @@ TYPED_TEST_P(AnyInvTestRvalue, NonMoveableResultType) {
// Just like plain functors, it should work fine to use an AnyInvocable that
// returns the non-moveable type.
using UnqualifiedFun =
absl::conditional_t<TypeParam::kIsNoexcept, Result() noexcept, Result()>;
std::conditional_t<TypeParam::kIsNoexcept, Result() noexcept, Result()>;
using Fun =
GiveQualifiersToFun<typename TypeParam::Qualifiers, UnqualifiedFun>;

View File

@@ -611,39 +611,39 @@ using TrueAlias =
/*SFINAE constraints for the conversion-constructor.*/
template <class Sig, class F,
class = absl::enable_if_t<
class = std::enable_if_t<
!std::is_same<RemoveCVRef<F>, AnyInvocable<Sig>>::value>>
using CanConvert = TrueAlias<
absl::enable_if_t<!IsInPlaceType<RemoveCVRef<F>>::value>,
absl::enable_if_t<Impl<Sig>::template CallIsValid<F>::value>,
absl::enable_if_t<
std::enable_if_t<!IsInPlaceType<RemoveCVRef<F>>::value>,
std::enable_if_t<Impl<Sig>::template CallIsValid<F>::value>,
std::enable_if_t<
Impl<Sig>::template CallIsNoexceptIfSigIsNoexcept<F>::value>,
absl::enable_if_t<std::is_constructible<absl::decay_t<F>, F>::value>>;
std::enable_if_t<std::is_constructible<std::decay_t<F>, F>::value>>;
/*SFINAE constraints for the std::in_place constructors.*/
template <class Sig, class F, class... Args>
using CanEmplace = TrueAlias<
absl::enable_if_t<Impl<Sig>::template CallIsValid<F>::value>,
absl::enable_if_t<
std::enable_if_t<Impl<Sig>::template CallIsValid<F>::value>,
std::enable_if_t<
Impl<Sig>::template CallIsNoexceptIfSigIsNoexcept<F>::value>,
absl::enable_if_t<std::is_constructible<absl::decay_t<F>, Args...>::value>>;
std::enable_if_t<std::is_constructible<std::decay_t<F>, Args...>::value>>;
/*SFINAE constraints for the conversion-assign operator.*/
template <class Sig, class F,
class = absl::enable_if_t<
class = std::enable_if_t<
!std::is_same<RemoveCVRef<F>, AnyInvocable<Sig>>::value>>
using CanAssign = TrueAlias<
absl::enable_if_t<Impl<Sig>::template CallIsValid<F>::value>,
absl::enable_if_t<
std::enable_if_t<Impl<Sig>::template CallIsValid<F>::value>,
std::enable_if_t<
Impl<Sig>::template CallIsNoexceptIfSigIsNoexcept<F>::value>,
absl::enable_if_t<std::is_constructible<absl::decay_t<F>, F>::value>>;
std::enable_if_t<std::is_constructible<std::decay_t<F>, F>::value>>;
/*SFINAE constraints for the reference-wrapper conversion-assign operator.*/
template <class Sig, class F>
using CanAssignReferenceWrapper = TrueAlias<
absl::enable_if_t<
std::enable_if_t<
Impl<Sig>::template CallIsValid<std::reference_wrapper<F>>::value>,
absl::enable_if_t<Impl<Sig>::template CallIsNoexceptIfSigIsNoexcept<
std::enable_if_t<Impl<Sig>::template CallIsNoexceptIfSigIsNoexcept<
std::reference_wrapper<F>>::value>>;
// The constraint for checking whether or not a call meets the noexcept
@@ -657,17 +657,17 @@ using CanAssignReferenceWrapper = TrueAlias<
// don't treat non-moveable result types correctly. For example this was the
// case in libc++ before commit c3a24882 (2022-05).
#define ABSL_INTERNAL_ANY_INVOCABLE_NOEXCEPT_CONSTRAINT_true(inv_quals) \
absl::enable_if_t<absl::disjunction< \
std::enable_if_t<std::disjunction< \
std::is_nothrow_invocable_r< \
ReturnType, UnwrapStdReferenceWrapper<absl::decay_t<F>> inv_quals, \
ReturnType, UnwrapStdReferenceWrapper<std::decay_t<F>> inv_quals, \
P...>, \
std::conjunction< \
std::is_nothrow_invocable< \
UnwrapStdReferenceWrapper<absl::decay_t<F>> inv_quals, P...>, \
UnwrapStdReferenceWrapper<std::decay_t<F>> inv_quals, P...>, \
std::is_same< \
ReturnType, \
std::invoke_result_t< \
UnwrapStdReferenceWrapper<absl::decay_t<F>> inv_quals, \
UnwrapStdReferenceWrapper<std::decay_t<F>> inv_quals, \
P...>>>>::value>
#define ABSL_INTERNAL_ANY_INVOCABLE_NOEXCEPT_CONSTRAINT_false(inv_quals)
@@ -696,11 +696,11 @@ using CanAssignReferenceWrapper = TrueAlias<
\
/*SFINAE constraint to check if F is invocable with the proper signature*/ \
template <class F> \
using CallIsValid = TrueAlias<absl::enable_if_t<absl::disjunction< \
std::is_invocable_r<ReturnType, absl::decay_t<F> inv_quals, P...>, \
using CallIsValid = TrueAlias<std::enable_if_t<std::disjunction< \
std::is_invocable_r<ReturnType, std::decay_t<F> inv_quals, P...>, \
std::is_same< \
ReturnType, \
std::invoke_result_t<absl::decay_t<F> inv_quals, P...>>>::value>>; \
std::invoke_result_t<std::decay_t<F> inv_quals, P...>>>::value>>; \
\
/*SFINAE constraint to check if F is nothrow-invocable when necessary*/ \
template <class F> \
@@ -723,7 +723,7 @@ using CanAssignReferenceWrapper = TrueAlias<
/*Forward along the in-place construction parameters.*/ \
template <class T, class... Args> \
explicit Impl(absl::in_place_type_t<T>, Args&&... args) \
: Core(absl::in_place_type<absl::decay_t<T> inv_quals>, \
: Core(absl::in_place_type<std::decay_t<T> inv_quals>, \
std::forward<Args>(args)...) {} \
\
/*Raises a fatal error when the AnyInvocable is invoked after a move*/ \

View File

@@ -84,7 +84,7 @@ class FrontBinder {
};
template <class F, class... BoundArgs>
using bind_front_t = FrontBinder<decay_t<F>, absl::decay_t<BoundArgs>...>;
using bind_front_t = FrontBinder<decay_t<F>, std::decay_t<BoundArgs>...>;
} // namespace functional_internal
ABSL_NAMESPACE_END

View File

@@ -47,8 +47,8 @@ struct PassByValue : std::false_type {};
template <typename T>
struct PassByValue<T, /*IsLValueReference=*/false>
: std::integral_constant<bool,
absl::is_trivially_copy_constructible<T>::value &&
absl::is_trivially_copy_assignable<
std::is_trivially_copy_constructible<T>::value &&
std::is_trivially_copy_assignable<
typename std::remove_cv<T>::type>::value &&
std::is_trivially_destructible<T>::value &&
sizeof(T) <= 2 * sizeof(void*)> {};

View File

@@ -329,7 +329,7 @@ class HashState : public hash_internal::HashStateBase<HashState> {
// users should not define their own HashState types.
template <
typename T,
absl::enable_if_t<
std::enable_if_t<
std::is_base_of<hash_internal::HashStateBase<T>, T>::value, int> = 0>
static HashState Create(T* state) {
HashState s;

View File

@@ -803,8 +803,8 @@ TEST(IsHashableTest, ValidHash) {
EXPECT_TRUE(std::is_default_constructible<absl::Hash<int>>::value);
EXPECT_TRUE(std::is_copy_constructible<absl::Hash<int>>::value);
EXPECT_TRUE(std::is_move_constructible<absl::Hash<int>>::value);
EXPECT_TRUE(absl::is_copy_assignable<absl::Hash<int>>::value);
EXPECT_TRUE(absl::is_move_assignable<absl::Hash<int>>::value);
EXPECT_TRUE(std::is_copy_assignable<absl::Hash<int>>::value);
EXPECT_TRUE(std::is_move_assignable<absl::Hash<int>>::value);
EXPECT_TRUE(IsHashCallable<int>::value);
EXPECT_TRUE(IsAggregateInitializable<absl::Hash<int>>::value);
}
@@ -815,8 +815,8 @@ TEST(IsHashableTest, PoisonHash) {
EXPECT_FALSE(std::is_default_constructible<absl::Hash<X>>::value);
EXPECT_FALSE(std::is_copy_constructible<absl::Hash<X>>::value);
EXPECT_FALSE(std::is_move_constructible<absl::Hash<X>>::value);
EXPECT_FALSE(absl::is_copy_assignable<absl::Hash<X>>::value);
EXPECT_FALSE(absl::is_move_assignable<absl::Hash<X>>::value);
EXPECT_FALSE(std::is_copy_assignable<absl::Hash<X>>::value);
EXPECT_FALSE(std::is_move_assignable<absl::Hash<X>>::value);
EXPECT_FALSE(IsHashCallable<X>::value);
#if !defined(__GNUC__) || defined(__clang__)
// TODO(b/144368551): As of GCC 8.4 this does not compile.
@@ -891,7 +891,7 @@ struct CustomHashType {
template <InvokeTag allowed, InvokeTag... tags>
struct EnableIfContained
: std::enable_if<absl::disjunction<
: std::enable_if<std::disjunction<
std::integral_constant<bool, allowed == tags>...>::value> {};
template <

View File

@@ -404,7 +404,7 @@ struct HashWithSeed {
// Convenience function that combines `hash_state` with the byte representation
// of `value`.
template <typename H, typename T,
absl::enable_if_t<FitsIn64Bits<T>::value, int> = 0>
std::enable_if_t<FitsIn64Bits<T>::value, int> = 0>
H hash_bytes(H hash_state, const T& value) {
const unsigned char* start = reinterpret_cast<const unsigned char*>(&value);
uint64_t v;
@@ -421,7 +421,7 @@ H hash_bytes(H hash_state, const T& value) {
return CombineRaw()(std::move(hash_state), v);
}
template <typename H, typename T,
absl::enable_if_t<!FitsIn64Bits<T>::value, int> = 0>
std::enable_if_t<!FitsIn64Bits<T>::value, int> = 0>
H hash_bytes(H hash_state, const T& value) {
const unsigned char* start = reinterpret_cast<const unsigned char*>(&value);
return H::combine_contiguous(std::move(hash_state), start, sizeof(value));
@@ -601,7 +601,7 @@ template <typename H, typename... Ts>
// for now.
H
#else // _MSC_VER
typename std::enable_if<absl::conjunction<is_hashable<Ts>...>::value, H>::type
typename std::enable_if<std::conjunction<is_hashable<Ts>...>::value, H>::type
#endif // _MSC_VER
AbslHashValue(H hash_state, const std::tuple<Ts...>& t) {
return hash_internal::hash_tuple(std::move(hash_state), t,
@@ -650,7 +650,7 @@ H AbslHashValue(H hash_state, absl::string_view str) {
// Support std::wstring, std::u16string and std::u32string.
template <typename Char, typename Alloc, typename H,
typename = absl::enable_if_t<std::is_same<Char, wchar_t>::value ||
typename = std::enable_if_t<std::is_same<Char, wchar_t>::value ||
std::is_same<Char, char16_t>::value ||
std::is_same<Char, char32_t>::value>>
H AbslHashValue(
@@ -661,7 +661,7 @@ H AbslHashValue(
// Support std::wstring_view, std::u16string_view and std::u32string_view.
template <typename Char, typename H,
typename = absl::enable_if_t<std::is_same<Char, wchar_t>::value ||
typename = std::enable_if_t<std::is_same<Char, wchar_t>::value ||
std::is_same<Char, char16_t>::value ||
std::is_same<Char, char32_t>::value>>
H AbslHashValue(H hash_state, std::basic_string_view<Char> str) {
@@ -680,7 +680,7 @@ H AbslHashValue(H hash_state, std::basic_string_view<Char> str) {
// Support std::filesystem::path. The SFINAE is required because some string
// types are implicitly convertible to std::filesystem::path.
template <typename Path, typename H,
typename = absl::enable_if_t<
typename = std::enable_if_t<
std::is_same_v<Path, std::filesystem::path>>>
H AbslHashValue(H hash_state, const Path& path) {
// This is implemented by deferring to the standard library to compute the
@@ -1299,14 +1299,14 @@ struct HashSelect {
struct UniquelyRepresentedProbe {
template <typename H, typename T>
static auto Invoke(H state, const T& value)
-> absl::enable_if_t<is_uniquely_represented<T>::value, H> {
-> std::enable_if_t<is_uniquely_represented<T>::value, H> {
return hash_internal::hash_bytes(std::move(state), value);
}
};
struct HashValueProbe {
template <typename H, typename T>
static auto Invoke(H state, const T& value) -> absl::enable_if_t<
static auto Invoke(H state, const T& value) -> std::enable_if_t<
std::is_same<H,
decltype(AbslHashValue(std::move(state), value))>::value,
H> {
@@ -1317,7 +1317,7 @@ struct HashSelect {
struct LegacyHashProbe {
#if ABSL_HASH_INTERNAL_SUPPORT_LEGACY_HASH_
template <typename H, typename T>
static auto Invoke(H state, const T& value) -> absl::enable_if_t<
static auto Invoke(H state, const T& value) -> std::enable_if_t<
std::is_convertible<
decltype(ABSL_INTERNAL_LEGACY_HASH_NAMESPACE::hash<T>()(value)),
size_t>::value,
@@ -1332,7 +1332,7 @@ struct HashSelect {
struct StdHashProbe {
template <typename H, typename T>
static auto Invoke(H state, const T& value)
-> absl::enable_if_t<type_traits_internal::IsHashable<T>::value, H> {
-> std::enable_if_t<type_traits_internal::IsHashable<T>::value, H> {
return hash_internal::hash_bytes(std::move(state), std::hash<T>{}(value));
}
};
@@ -1354,7 +1354,7 @@ struct HashSelect {
// Probe each implementation in order.
// disjunction provides short circuiting wrt instantiation.
template <typename T>
using Apply = absl::disjunction< //
using Apply = std::disjunction< //
Probe<WeaklyMixedIntegerProbe, T>, //
Probe<UniquelyRepresentedProbe, T>, //
Probe<HashValueProbe, T>, //
@@ -1399,13 +1399,13 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
// Otherwise we would be instantiating and calling dozens of functions for
// something that is just one multiplication and a couple xor's.
// The result should be the same as running the whole algorithm, but faster.
template <typename T, absl::enable_if_t<IntegralFastPath<T>::value, int> = 0>
template <typename T, std::enable_if_t<IntegralFastPath<T>::value, int> = 0>
static size_t hash_with_seed(T value, size_t seed) {
return static_cast<size_t>(
CombineRawImpl(seed, static_cast<std::make_unsigned_t<T>>(value)));
}
template <typename T, absl::enable_if_t<!IntegralFastPath<T>::value, int> = 0>
template <typename T, std::enable_if_t<!IntegralFastPath<T>::value, int> = 0>
static size_t hash_with_seed(const T& value, size_t seed) {
return static_cast<size_t>(combine(MixingHashState{seed}, value).state_);
}
@@ -1527,7 +1527,7 @@ struct HashImpl {
template <typename T>
struct Hash
: absl::conditional_t<is_hashable<T>::value, HashImpl<T>, PoisonedHash> {};
: std::conditional_t<is_hashable<T>::value, HashImpl<T>, PoisonedHash> {};
template <typename H>
template <typename T, typename... Ts>

View File

@@ -22,6 +22,7 @@
#include <optional>
#include <ostream>
#include <string>
#include <type_traits>
#include <vector>
#include "absl/hash/hash.h"
@@ -269,7 +270,7 @@ bool RunOnStartup<f>::run = (f(), true);
template <
typename T, typename U,
// Only trigger for when (T != U),
typename = absl::enable_if_t<!std::is_same<T, U>::value>,
typename = std::enable_if_t<!std::is_same<T, U>::value>,
// This statement works in two ways:
// - First, it instantiates RunOnStartup and forces the initialization of
// `run`, which set the global variable.

View File

@@ -134,7 +134,7 @@ typename memory_internal::MakeUniqueResult<T>::scalar
template <typename T>
typename memory_internal::MakeUniqueResult<T>::array
make_unique_for_overwrite(size_t n) {
return std::unique_ptr<T>(new typename absl::remove_extent_t<T>[n]);
return std::unique_ptr<T>(new typename std::remove_extent_t<T>[n]);
}
// `absl::make_unique_for_overwrite` overload for an array T[N] of known bounds.

View File

@@ -218,7 +218,7 @@ struct IsHashable : std::false_type {};
template <typename Key>
struct IsHashable<
Key,
absl::enable_if_t<std::is_convertible<
std::enable_if_t<std::is_convertible<
decltype(std::declval<std::hash<Key>&>()(std::declval<Key const&>())),
std::size_t>::value>> : std::true_type {};
@@ -243,7 +243,7 @@ struct AssertHashEnabledHelper {
static_assert(
std::is_copy_constructible<std::hash<Key>>::value,
"std::hash<Key> must be copy constructible when it is enabled");
static_assert(absl::is_copy_assignable<std::hash<Key>>::value,
static_assert(std::is_copy_assignable<std::hash<Key>>::value,
"std::hash<Key> must be copy assignable when it is enabled");
// is_destructible is unchecked as it's implied by each of the
// is_constructible checks.
@@ -306,7 +306,7 @@ struct IsNothrowSwappable
//
// Performs the swap idiom from a namespace where valid candidates may only be
// found in `std` or via ADL.
template <class T, absl::enable_if_t<IsSwappable<T>::value, int> = 0>
template <class T, std::enable_if_t<IsSwappable<T>::value, int> = 0>
void Swap(T& lhs, T& rhs) noexcept(IsNothrowSwappable<T>::value) {
swap(lhs, rhs);
}
@@ -475,7 +475,7 @@ template <typename T>
struct IsOwnerImpl<
T,
std::enable_if_t<std::is_class<typename T::absl_internal_is_view>::value>>
: absl::negation<typename T::absl_internal_is_view> {};
: std::negation<typename T::absl_internal_is_view> {};
// A trait to determine whether a type is an owner.
// Do *not* depend on the correctness of this trait for correct code behavior.
@@ -555,7 +555,7 @@ struct IsView<std::span<T>> : std::true_type {};
// Until then, we consider an assignment from an "owner" (such as std::string)
// to a "view" (such as std::string_view) to be a lifetime-bound assignment.
template <typename T, typename U>
using IsLifetimeBoundAssignment = absl::conjunction<
using IsLifetimeBoundAssignment = std::conjunction<
std::integral_constant<bool, !std::is_lvalue_reference<U>::value>,
IsOwner<absl::remove_cvref_t<U>>, IsView<absl::remove_cvref_t<T>>>;

View File

@@ -33,8 +33,8 @@ using ::testing::StaticAssertTypeEq;
template <typename T>
using IsOwnerAndNotView =
absl::conjunction<absl::type_traits_internal::IsOwner<T>,
absl::negation<absl::type_traits_internal::IsView<T>>>;
std::conjunction<absl::type_traits_internal::IsOwner<T>,
std::negation<absl::type_traits_internal::IsView<T>>>;
static_assert(
IsOwnerAndNotView<std::pair<std::vector<int>, std::string>>::value,
@@ -70,13 +70,13 @@ struct StructC {};
struct TypeWithBarFunction {
template <class T,
absl::enable_if_t<std::is_same<T&&, StructA&>::value, int> = 0>
std::enable_if_t<std::is_same<T&&, StructA&>::value, int> = 0>
ReturnType bar(T&&, const StructB&, StructC&&) &&; // NOLINT
};
struct TypeWithBarFunctionAndConvertibleReturnType {
template <class T,
absl::enable_if_t<std::is_same<T&&, StructA&>::value, int> = 0>
std::enable_if_t<std::is_same<T&&, StructA&>::value, int> = 0>
ConvertibleToReturnType bar(T&&, const StructB&, StructC&&) &&; // NOLINT
};
@@ -160,19 +160,19 @@ enum class TypeEnum { A, B, C, D };
struct GetTypeT {
template <typename T,
absl::enable_if_t<std::is_same<T, TypeA>::value, int> = 0>
std::enable_if_t<std::is_same<T, TypeA>::value, int> = 0>
TypeEnum operator()(Wrap<T>) const {
return TypeEnum::A;
}
template <typename T,
absl::enable_if_t<std::is_same<T, TypeB>::value, int> = 0>
std::enable_if_t<std::is_same<T, TypeB>::value, int> = 0>
TypeEnum operator()(Wrap<T>) const {
return TypeEnum::B;
}
template <typename T,
absl::enable_if_t<std::is_same<T, TypeC>::value, int> = 0>
std::enable_if_t<std::is_same<T, TypeC>::value, int> = 0>
TypeEnum operator()(Wrap<T>) const {
return TypeEnum::C;
}

View File

@@ -93,11 +93,11 @@ TEST(Uint128, IntrinsicTypeTraitsTest) {
#endif // ABSL_HAVE_INTRINSIC_INT128
TEST(Uint128, TrivialTraitsTest) {
static_assert(absl::is_trivially_default_constructible<absl::uint128>::value,
static_assert(std::is_trivially_default_constructible<absl::uint128>::value,
"");
static_assert(absl::is_trivially_copy_constructible<absl::uint128>::value,
static_assert(std::is_trivially_copy_constructible<absl::uint128>::value,
"");
static_assert(absl::is_trivially_copy_assignable<absl::uint128>::value, "");
static_assert(std::is_trivially_copy_assignable<absl::uint128>::value, "");
static_assert(std::is_trivially_destructible<absl::uint128>::value, "");
}
@@ -619,10 +619,10 @@ TEST(Int128, IntrinsicTypeTraitsTest) {
#endif // ABSL_HAVE_INTRINSIC_INT128
TEST(Int128, TrivialTraitsTest) {
static_assert(absl::is_trivially_default_constructible<absl::int128>::value,
static_assert(std::is_trivially_default_constructible<absl::int128>::value,
"");
static_assert(absl::is_trivially_copy_constructible<absl::int128>::value, "");
static_assert(absl::is_trivially_copy_assignable<absl::int128>::value, "");
static_assert(std::is_trivially_copy_constructible<absl::int128>::value, "");
static_assert(std::is_trivially_copy_assignable<absl::int128>::value, "");
static_assert(std::is_trivially_destructible<absl::int128>::value, "");
}

View File

@@ -282,7 +282,7 @@ beta_distribution<RealType>::AlgorithmJoehnk(
using random_internal::GeneratePositiveTag;
using random_internal::GenerateRealFromBits;
using real_type =
absl::conditional_t<std::is_same<RealType, float>::value, float, double>;
std::conditional_t<std::is_same<RealType, float>::value, float, double>;
// Based on Joehnk, M. D. Erzeugung von betaverteilten und gammaverteilten
// Zufallszahlen. Metrika 8.1 (1964): 5-15.
@@ -340,7 +340,7 @@ beta_distribution<RealType>::AlgorithmCheng(
using random_internal::GeneratePositiveTag;
using random_internal::GenerateRealFromBits;
using real_type =
absl::conditional_t<std::is_same<RealType, float>::value, float, double>;
std::conditional_t<std::is_same<RealType, float>::value, float, double>;
// Based on Cheng, Russell CH. Generating beta variates with nonintegral
// shape parameters. Communications of the ACM 21.4 (1978): 317-322.

View File

@@ -83,7 +83,7 @@ class BitGenRef {
BitGenRef& operator=(BitGenRef&&) = default;
template <typename URBGRef, typename URBG = absl::remove_cvref_t<URBGRef>,
typename absl::enable_if_t<
typename std::enable_if_t<
(!std::is_same<URBG, BitGenRef>::value &&
!std::is_base_of<BitGenRef, URBG>::value &&
!HasConversionOperator<URBG>::value &&
@@ -95,7 +95,7 @@ class BitGenRef {
generate_impl_fn_(ImplFn<URBG>) {}
template <typename URBGRef, typename URBG = absl::remove_cvref_t<URBGRef>,
typename absl::enable_if_t<
typename std::enable_if_t<
(!std::is_same<URBG, BitGenRef>::value &&
!std::is_base_of<BitGenRef, URBG>::value &&
!HasConversionOperator<URBG>::value &&

View File

@@ -117,11 +117,11 @@ inline constexpr IntervalOpenClosedTag IntervalOpenClosed = {};
// auto x = absl::Uniform<float>(bitgen, 0, 1);
//
template <typename R = void, typename TagType, typename URBG>
typename absl::enable_if_t<!std::is_same<R, void>::value, R> //
typename std::enable_if_t<!std::is_same<R, void>::value, R> //
Uniform(TagType tag,
URBG&& urbg, // NOLINT(runtime/references)
R lo, R hi) {
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = random_internal::UniformDistributionWrapper<R>;
auto a = random_internal::uniform_lower_bound(tag, lo, hi);
@@ -137,10 +137,10 @@ Uniform(TagType tag,
// Overload of `Uniform()` using the default closed-open interval of [lo, hi),
// and returning values of type `T`
template <typename R = void, typename URBG>
typename absl::enable_if_t<!std::is_same<R, void>::value, R> //
typename std::enable_if_t<!std::is_same<R, void>::value, R> //
Uniform(URBG&& urbg, // NOLINT(runtime/references)
R lo, R hi) {
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = random_internal::UniformDistributionWrapper<R>;
constexpr auto tag = absl::IntervalClosedOpen;
@@ -159,12 +159,12 @@ Uniform(URBG&& urbg, // NOLINT(runtime/references)
// correctly from the passed types.
template <typename R = void, typename TagType, typename URBG, typename A,
typename B>
typename absl::enable_if_t<std::is_same<R, void>::value,
typename std::enable_if_t<std::is_same<R, void>::value,
random_internal::uniform_inferred_return_t<A, B>>
Uniform(TagType tag,
URBG&& urbg, // NOLINT(runtime/references)
A lo, B hi) {
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using return_t = typename random_internal::uniform_inferred_return_t<A, B>;
using distribution_t = random_internal::UniformDistributionWrapper<return_t>;
@@ -183,11 +183,11 @@ Uniform(TagType tag,
// default closed-open interval of [lo, hi). Note that a compile-error will
// result if the return type cannot be deduced correctly from the passed types.
template <typename R = void, typename URBG, typename A, typename B>
typename absl::enable_if_t<std::is_same<R, void>::value,
typename std::enable_if_t<std::is_same<R, void>::value,
random_internal::uniform_inferred_return_t<A, B>>
Uniform(URBG&& urbg, // NOLINT(runtime/references)
A lo, B hi) {
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using return_t = typename random_internal::uniform_inferred_return_t<A, B>;
using distribution_t = random_internal::UniformDistributionWrapper<return_t>;
@@ -206,9 +206,9 @@ Uniform(URBG&& urbg, // NOLINT(runtime/references)
// Overload of Uniform() using the minimum and maximum values of a given type
// `T` (which must be unsigned), returning a value of type `unsigned T`
template <typename R, typename URBG>
typename absl::enable_if_t<!std::numeric_limits<R>::is_signed, R> //
typename std::enable_if_t<!std::numeric_limits<R>::is_signed, R> //
Uniform(URBG&& urbg) { // NOLINT(runtime/references)
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = random_internal::UniformDistributionWrapper<R>;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -238,7 +238,7 @@ Uniform(URBG&& urbg) { // NOLINT(runtime/references)
template <typename URBG>
bool Bernoulli(URBG&& urbg, // NOLINT(runtime/references)
double p) {
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = absl::bernoulli_distribution;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -270,7 +270,7 @@ RealType Beta(URBG&& urbg, // NOLINT(runtime/references)
"Template-argument 'RealType' must be a floating-point type, in "
"absl::Beta<RealType, URBG>(...)");
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = typename absl::beta_distribution<RealType>;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -302,7 +302,7 @@ RealType Exponential(URBG&& urbg, // NOLINT(runtime/references)
"Template-argument 'RealType' must be a floating-point type, in "
"absl::Exponential<RealType, URBG>(...)");
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = typename absl::exponential_distribution<RealType>;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -333,7 +333,7 @@ RealType Gaussian(URBG&& urbg, // NOLINT(runtime/references)
"Template-argument 'RealType' must be a floating-point type, in "
"absl::Gaussian<RealType, URBG>(...)");
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = typename absl::gaussian_distribution<RealType>;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -375,7 +375,7 @@ IntType LogUniform(URBG&& urbg, // NOLINT(runtime/references)
"Template-argument 'IntType' must be an integral type, in "
"absl::LogUniform<IntType, URBG>(...)");
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = typename absl::log_uniform_int_distribution<IntType>;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -405,7 +405,7 @@ IntType Poisson(URBG&& urbg, // NOLINT(runtime/references)
"Template-argument 'IntType' must be an integral type, in "
"absl::Poisson<IntType, URBG>(...)");
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = typename absl::poisson_distribution<IntType>;
return random_internal::DistributionCaller<gen_t>::template Call<
@@ -437,7 +437,7 @@ IntType Zipf(URBG&& urbg, // NOLINT(runtime/references)
"Template-argument 'IntType' must be an integral type, in "
"absl::Zipf<IntType, URBG>(...)");
using gen_t = absl::decay_t<URBG>;
using gen_t = std::decay_t<URBG>;
using distribution_t = typename absl::zipf_distribution<IntType>;
return random_internal::DistributionCaller<gen_t>::template Call<

View File

@@ -80,13 +80,13 @@ Invalid InferredTaggedUniformReturnT(...);
template <typename A, typename B, typename Expect>
void CheckArgsInferType() {
static_assert(
absl::conjunction<
std::conjunction<
std::is_same<Expect, decltype(InferredUniformReturnT<A, B>(0))>,
std::is_same<Expect,
decltype(InferredUniformReturnT<B, A>(0))>>::value,
"");
static_assert(
absl::conjunction<
std::conjunction<
std::is_same<Expect, decltype(InferredTaggedUniformReturnT<
absl::IntervalOpenOpenTag, A, B>(0))>,
std::is_same<Expect,
@@ -121,14 +121,14 @@ Invalid ExplicitTaggedUniformReturnT(...);
template <typename A, typename B, typename Expect>
void CheckArgsReturnExpectedType() {
static_assert(
absl::conjunction<
std::conjunction<
std::is_same<Expect,
decltype(ExplicitUniformReturnT<A, B, Expect>(0))>,
std::is_same<Expect, decltype(ExplicitUniformReturnT<B, A, Expect>(
0))>>::value,
"");
static_assert(
absl::conjunction<
std::conjunction<
std::is_same<Expect,
decltype(ExplicitTaggedUniformReturnT<
absl::IntervalOpenOpenTag, A, B, Expect>(0))>,

View File

@@ -124,7 +124,7 @@ exponential_distribution<RealType>::operator()(
using random_internal::GenerateNegativeTag;
using random_internal::GenerateRealFromBits;
using real_type =
absl::conditional_t<std::is_same<RealType, float>::value, float, double>;
std::conditional_t<std::is_same<RealType, float>::value, float, double>;
const result_type u = GenerateRealFromBits<real_type, GenerateNegativeTag,
false>(fast_u64_(g)); // U(-1, 0)

View File

@@ -55,7 +55,7 @@ struct DistributionCaller {
static typename DistrT::result_type Impl(std::true_type, URBG* urbg,
Args&&... args) {
using ResultT = typename DistrT::result_type;
using ArgTupleT = std::tuple<absl::decay_t<Args>...>;
using ArgTupleT = std::tuple<std::decay_t<Args>...>;
using KeyT = ResultT(DistrT, ArgTupleT);
ArgTupleT arg_tuple(std::forward<Args>(args)...);

View File

@@ -126,7 +126,7 @@ FastUniformBits<UIntType>::operator()(URBG& g) { // NOLINT(runtime/references)
static_assert((URBG::max)() > (URBG::min)(),
"URBG::max and URBG::min may not be equal.");
using tag = absl::conditional_t<IsPowerOfTwoOrZero(RangeSize<URBG>()),
using tag = std::conditional_t<IsPowerOfTwoOrZero(RangeSize<URBG>()),
SimplifiedLoopTag, RejectionLoopTag>;
return Generate(g, tag{});
}

View File

@@ -69,7 +69,7 @@ template <typename RealType, // Real type, either float or double.
bool IncludeZero = true>
inline RealType GenerateRealFromBits(uint64_t bits, int exp_bias = 0) {
using real_type = RealType;
using uint_type = absl::conditional_t<std::is_same<real_type, float>::value,
using uint_type = std::conditional_t<std::is_same<real_type, float>::value,
uint32_t, uint64_t>;
static_assert(

View File

@@ -95,7 +95,7 @@ ostream_state_saver<std::basic_ostream<CharT, Traits>> make_ostream_state_saver(
}
template <typename T>
typename absl::enable_if_t<!std::is_base_of<std::ios_base, T>::value,
typename std::enable_if_t<!std::is_base_of<std::ios_base, T>::value,
null_state_saver<T>>
make_ostream_state_saver(T& is, // NOLINT(runtime/references)
std::ios_base::fmtflags flags = std::ios_base::dec) {
@@ -159,7 +159,7 @@ istream_state_saver<std::basic_istream<CharT, Traits>> make_istream_state_saver(
}
template <typename T>
typename absl::enable_if_t<!std::is_base_of<std::ios_base, T>::value,
typename std::enable_if_t<!std::is_base_of<std::ios_base, T>::value,
null_state_saver<T>>
make_istream_state_saver(T& is, // NOLINT(runtime/references)
std::ios_base::fmtflags flags = std::ios_base::dec) {

View File

@@ -19,6 +19,7 @@
#include <sstream>
#include <string>
#include <type_traits>
#include "gtest/gtest.h"
@@ -29,7 +30,7 @@ using absl::random_internal::make_ostream_state_saver;
using absl::random_internal::stream_precision_helper;
template <typename T>
typename absl::enable_if_t<std::is_integral<T>::value, T> //
typename std::enable_if_t<std::is_integral<T>::value, T> //
StreamRoundTrip(T t) {
std::stringstream ss;
{
@@ -53,7 +54,7 @@ StreamRoundTrip(T t) {
}
template <typename T>
typename absl::enable_if_t<std::is_floating_point<T>::value, T> //
typename std::enable_if_t<std::is_floating_point<T>::value, T> //
StreamRoundTrip(T t) {
std::stringstream ss;
{

View File

@@ -78,7 +78,7 @@ class RandenPoolSeedSeq {
// std::contiguous_iterator_tag provides a mechanism for testing this
// capability, however until Abseil's support requirements allow us to
// assume C++20, limit checks to a few common cases.
using TagType = absl::conditional_t<
using TagType = std::conditional_t<
(std::is_pointer<RandomAccessIterator>::value ||
std::is_same<RandomAccessIterator,
typename std::vector<U>::iterator>::value),
@@ -106,7 +106,7 @@ class NonsecureURBGBase {
NonsecureURBGBase& operator=(NonsecureURBGBase&&) = default;
// Constructor using a seed
template <class SSeq, typename = typename absl::enable_if_t<
template <class SSeq, typename = typename std::enable_if_t<
!std::is_same<SSeq, NonsecureURBGBase>::value>>
explicit NonsecureURBGBase(SSeq&& seq)
: urbg_(ConstructURBG(std::forward<SSeq>(seq))) {}

View File

@@ -77,13 +77,13 @@ TEST(NonsecureURBGBase, StandardInterface) {
static_assert(!std::is_copy_constructible<E>::value,
"NonsecureURBGBase should not be copy constructible");
static_assert(!absl::is_copy_assignable<E>::value,
static_assert(!std::is_copy_assignable<E>::value,
"NonsecureURBGBase should not be copy assignable");
static_assert(std::is_move_constructible<E>::value,
"NonsecureURBGBase should be move constructible");
static_assert(absl::is_move_assignable<E>::value,
static_assert(std::is_move_assignable<E>::value,
"NonsecureURBGBase should be move assignable");
static_assert(std::is_same<decltype(std::declval<E>()()), T>::value,

View File

@@ -67,7 +67,7 @@ class pcg_engine {
explicit pcg_engine(uint64_t seed_value = 0) { seed(seed_value); }
template <class SeedSequence,
typename = typename absl::enable_if_t<
typename = typename std::enable_if_t<
!std::is_same<SeedSequence, pcg_engine>::value>>
explicit pcg_engine(SeedSequence&& seq) {
seed(seq);
@@ -90,7 +90,7 @@ class pcg_engine {
}
template <class SeedSequence>
typename absl::enable_if_t<
typename std::enable_if_t<
!std::is_convertible<SeedSequence, uint64_t>::value, void>
seed(SeedSequence&& seq) {
reseed(seq);
@@ -105,7 +105,7 @@ class pcg_engine {
bool operator!=(const pcg_engine& other) const { return !(*this == other); }
template <class CharT, class Traits>
friend typename absl::enable_if_t<(sizeof(state_type) == 16),
friend typename std::enable_if_t<(sizeof(state_type) == 16),
std::basic_ostream<CharT, Traits>&>
operator<<(
std::basic_ostream<CharT, Traits>& os, // NOLINT(runtime/references)
@@ -121,7 +121,7 @@ class pcg_engine {
}
template <class CharT, class Traits>
friend typename absl::enable_if_t<(sizeof(state_type) <= 8),
friend typename std::enable_if_t<(sizeof(state_type) <= 8),
std::basic_ostream<CharT, Traits>&>
operator<<(
std::basic_ostream<CharT, Traits>& os, // NOLINT(runtime/references)
@@ -134,7 +134,7 @@ class pcg_engine {
}
template <class CharT, class Traits>
friend typename absl::enable_if_t<(sizeof(state_type) == 16),
friend typename std::enable_if_t<(sizeof(state_type) == 16),
std::basic_istream<CharT, Traits>&>
operator>>(
std::basic_istream<CharT, Traits>& is, // NOLINT(runtime/references)
@@ -155,7 +155,7 @@ class pcg_engine {
}
template <class CharT, class Traits>
friend typename absl::enable_if_t<(sizeof(state_type) <= 8),
friend typename std::enable_if_t<(sizeof(state_type) <= 8),
std::basic_istream<CharT, Traits>&>
operator>>(
std::basic_istream<CharT, Traits>& is, // NOLINT(runtime/references)

View File

@@ -18,6 +18,7 @@
#include <bitset>
#include <random>
#include <sstream>
#include <type_traits>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -169,13 +170,13 @@ TYPED_TEST(PCGEngineTest, RandomNumberEngineInterface) {
static_assert(std::is_copy_constructible<E>::value,
"engine_type must be copy constructible");
static_assert(absl::is_copy_assignable<E>::value,
static_assert(std::is_copy_assignable<E>::value,
"engine_type must be copy assignable");
static_assert(std::is_move_constructible<E>::value,
"engine_type must be move constructible");
static_assert(absl::is_move_assignable<E>::value,
static_assert(std::is_move_assignable<E>::value,
"engine_type must be move assignable");
static_assert(std::is_same<decltype(std::declval<E>()()), T>::value,

View File

@@ -63,7 +63,7 @@ class alignas(8) randen_engine {
explicit randen_engine(result_type seed_value) { seed(seed_value); }
template <class SeedSequence,
typename = typename absl::enable_if_t<
typename = typename std::enable_if_t<
!std::is_same<SeedSequence, randen_engine>::value>>
explicit randen_engine(SeedSequence&& seq) {
seed(seq);
@@ -93,7 +93,7 @@ class alignas(8) randen_engine {
}
template <class SeedSequence>
typename absl::enable_if_t<
typename std::enable_if_t<
!std::is_convertible<SeedSequence, result_type>::value>
seed(SeedSequence&& seq) {
// Zeroes the state.

View File

@@ -18,6 +18,7 @@
#include <bitset>
#include <random>
#include <sstream>
#include <type_traits>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -170,13 +171,13 @@ TYPED_TEST(RandenEngineTypedTest, RandomNumberEngineInterface) {
static_assert(std::is_copy_constructible<E>::value,
"randen_engine must be copy constructible");
static_assert(absl::is_copy_assignable<E>::value,
static_assert(std::is_copy_assignable<E>::value,
"randen_engine must be copy assignable");
static_assert(std::is_move_constructible<E>::value,
"randen_engine must be move constructible");
static_assert(absl::is_move_assignable<E>::value,
static_assert(std::is_move_assignable<E>::value,
"randen_engine must be move assignable");
static_assert(std::is_same<decltype(std::declval<E>()()), T>::value,

View File

@@ -15,6 +15,7 @@
#include "absl/random/internal/randen.h"
#include <cstring>
#include <type_traits>
#include "gtest/gtest.h"
#include "absl/meta/type_traits.h"
@@ -27,13 +28,13 @@ TEST(RandenTest, CopyAndMove) {
static_assert(std::is_copy_constructible<Randen>::value,
"Randen must be copy constructible");
static_assert(absl::is_copy_assignable<Randen>::value,
static_assert(std::is_copy_assignable<Randen>::value,
"Randen must be copy assignable");
static_assert(std::is_move_constructible<Randen>::value,
"Randen must be move constructible");
static_assert(absl::is_move_assignable<Randen>::value,
static_assert(std::is_move_assignable<Randen>::value,
"Randen must be move assignable");
}

View File

@@ -72,7 +72,7 @@ class SaltedSeedSeq {
// The common case is that generate is called with ContiguousIterators
// to uint arrays. Such contiguous memory regions may be optimized,
// which we detect here.
using TagType = absl::conditional_t<
using TagType = std::conditional_t<
(std::is_same<U, uint32_t>::value &&
(std::is_pointer<RandomAccessIterator>::value ||
std::is_same<RandomAccessIterator,
@@ -142,14 +142,14 @@ struct is_salted_seed_seq<
// non-salted seed parameters.
template <
typename SSeq, //
typename EnableIf = absl::enable_if_t<is_salted_seed_seq<SSeq>::value>>
typename EnableIf = std::enable_if_t<is_salted_seed_seq<SSeq>::value>>
SSeq MakeSaltedSeedSeq(SSeq&& seq) {
return SSeq(std::forward<SSeq>(seq));
}
template <
typename SSeq, //
typename EnableIf = absl::enable_if_t<!is_salted_seed_seq<SSeq>::value>>
typename EnableIf = std::enable_if_t<!is_salted_seed_seq<SSeq>::value>>
SaltedSeedSeq<typename std::decay<SSeq>::type> MakeSaltedSeedSeq(SSeq&& seq) {
using sseq_type = typename std::decay<SSeq>::type;
using result_type = typename sseq_type::result_type;

View File

@@ -37,13 +37,13 @@ struct is_urbg : std::false_type {};
template <typename URBG>
struct is_urbg<
URBG,
absl::enable_if_t<std::is_same<
std::enable_if_t<std::is_same<
typename URBG::result_type,
typename std::decay<decltype((URBG::min)())>::type>::value>,
absl::enable_if_t<std::is_same<
std::enable_if_t<std::is_same<
typename URBG::result_type,
typename std::decay<decltype((URBG::max)())>::type>::value>,
absl::enable_if_t<std::is_same<
std::enable_if_t<std::is_same<
typename URBG::result_type,
typename std::decay<decltype(std::declval<URBG>()())>::type>::value>>
: std::true_type {};

View File

@@ -76,7 +76,7 @@ namespace random_internal {
// Return-type for absl::Uniform() when the return-type is inferred.
template <typename A, typename B>
using uniform_inferred_return_t =
absl::enable_if_t<absl::disjunction<is_widening_convertible<A, B>,
std::enable_if_t<std::disjunction<is_widening_convertible<A, B>,
is_widening_convertible<B, A>>::value,
typename std::conditional<
is_widening_convertible<A, B>::value, B, A>::type>;
@@ -98,10 +98,10 @@ using uniform_inferred_return_t =
// uniform_upper_bound(IntervalOpenClosed, a, b)]
//
template <typename IntType, typename Tag>
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
IsIntegral<IntType>,
absl::disjunction<std::is_same<Tag, IntervalOpenClosedTag>,
std::disjunction<std::is_same<Tag, IntervalOpenClosedTag>,
std::is_same<Tag, IntervalOpenOpenTag>>>::value,
IntType>
uniform_lower_bound(Tag, IntType a, IntType) {
@@ -109,10 +109,10 @@ uniform_lower_bound(Tag, IntType a, IntType) {
}
template <typename FloatType, typename Tag>
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_floating_point<FloatType>,
absl::disjunction<std::is_same<Tag, IntervalOpenClosedTag>,
std::disjunction<std::is_same<Tag, IntervalOpenClosedTag>,
std::is_same<Tag, IntervalOpenOpenTag>>>::value,
FloatType>
uniform_lower_bound(Tag, FloatType a, FloatType b) {
@@ -120,8 +120,8 @@ uniform_lower_bound(Tag, FloatType a, FloatType b) {
}
template <typename NumType, typename Tag>
typename absl::enable_if_t<
absl::disjunction<std::is_same<Tag, IntervalClosedClosedTag>,
typename std::enable_if_t<
std::disjunction<std::is_same<Tag, IntervalClosedClosedTag>,
std::is_same<Tag, IntervalClosedOpenTag>>::value,
NumType>
uniform_lower_bound(Tag, NumType a, NumType) {
@@ -129,10 +129,10 @@ uniform_lower_bound(Tag, NumType a, NumType) {
}
template <typename IntType, typename Tag>
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
IsIntegral<IntType>,
absl::disjunction<std::is_same<Tag, IntervalClosedOpenTag>,
std::disjunction<std::is_same<Tag, IntervalClosedOpenTag>,
std::is_same<Tag, IntervalOpenOpenTag>>>::value,
IntType>
uniform_upper_bound(Tag, IntType, IntType b) {
@@ -140,10 +140,10 @@ uniform_upper_bound(Tag, IntType, IntType b) {
}
template <typename FloatType, typename Tag>
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_floating_point<FloatType>,
absl::disjunction<std::is_same<Tag, IntervalClosedOpenTag>,
std::disjunction<std::is_same<Tag, IntervalClosedOpenTag>,
std::is_same<Tag, IntervalOpenOpenTag>>>::value,
FloatType>
uniform_upper_bound(Tag, FloatType, FloatType b) {
@@ -151,10 +151,10 @@ uniform_upper_bound(Tag, FloatType, FloatType b) {
}
template <typename IntType, typename Tag>
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
IsIntegral<IntType>,
absl::disjunction<std::is_same<Tag, IntervalClosedClosedTag>,
std::disjunction<std::is_same<Tag, IntervalClosedClosedTag>,
std::is_same<Tag, IntervalOpenClosedTag>>>::value,
IntType>
uniform_upper_bound(Tag, IntType, IntType b) {
@@ -162,10 +162,10 @@ uniform_upper_bound(Tag, IntType, IntType b) {
}
template <typename FloatType, typename Tag>
typename absl::enable_if_t<
absl::conjunction<
typename std::enable_if_t<
std::conjunction<
std::is_floating_point<FloatType>,
absl::disjunction<std::is_same<Tag, IntervalClosedClosedTag>,
std::disjunction<std::is_same<Tag, IntervalClosedClosedTag>,
std::is_same<Tag, IntervalOpenClosedTag>>>::value,
FloatType>
uniform_upper_bound(Tag, FloatType, FloatType b) {
@@ -195,13 +195,13 @@ uniform_upper_bound(Tag, FloatType, FloatType b) {
// (0, 0] is not legal, but (0, 0+epsilon] is.
//
template <typename FloatType>
absl::enable_if_t<std::is_floating_point<FloatType>::value, bool>
std::enable_if_t<std::is_floating_point<FloatType>::value, bool>
is_uniform_range_valid(FloatType a, FloatType b) {
return a <= b && std::isfinite(b - a);
}
template <typename IntType>
absl::enable_if_t<IsIntegral<IntType>::value, bool> is_uniform_range_valid(
std::enable_if_t<IsIntegral<IntType>::value, bool> is_uniform_range_valid(
IntType a, IntType b) {
return a <= b;
}

View File

@@ -17,6 +17,7 @@
#include <cmath>
#include <cstdint>
#include <random>
#include <type_traits>
#include "gtest/gtest.h"
@@ -214,7 +215,7 @@ Invalid InferredUniformReturnT(...);
template <typename A, typename B, typename Expect>
void CheckArgsInferType() {
static_assert(
absl::conjunction<
std::conjunction<
std::is_same<Expect, decltype(InferredUniformReturnT<A, B>(0))>,
std::is_same<Expect,
decltype(InferredUniformReturnT<B, A>(0))>>::value,

View File

@@ -174,13 +174,13 @@ class MockingBitGen {
using MockFnType = decltype(GetMockFnType(std::declval<ResultT>(),
std::declval<ArgTupleT>()));
using WrappedFnType = absl::conditional_t<
using WrappedFnType = std::conditional_t<
std::is_same<SelfT, ::testing::NiceMock<MockingBitGen>>::value,
::testing::NiceMock<MockFnType>,
absl::conditional_t<
std::conditional_t<
std::is_same<SelfT, ::testing::NaggyMock<MockingBitGen>>::value,
::testing::NaggyMock<MockFnType>,
absl::conditional_t<
std::conditional_t<
std::is_same<SelfT,
::testing::StrictMock<MockingBitGen>>::value,
::testing::StrictMock<MockFnType>, MockFnType>>>;

View File

@@ -159,7 +159,7 @@ uniform_real_distribution<RealType>::operator()(
using random_internal::GeneratePositiveTag;
using random_internal::GenerateRealFromBits;
using real_type =
absl::conditional_t<std::is_same<RealType, float>::value, float, double>;
std::conditional_t<std::is_same<RealType, float>::value, float, double>;
while (true) {
const result_type sample =

View File

@@ -60,7 +60,7 @@ struct IsEqualityComparable<
// Detects whether `T` is constructible or convertible from `StatusOr<U>`.
template <typename T, typename U>
using IsConstructibleOrConvertibleFromStatusOr =
absl::disjunction<std::is_constructible<T, StatusOr<U>&>,
std::disjunction<std::is_constructible<T, StatusOr<U>&>,
std::is_constructible<T, const StatusOr<U>&>,
std::is_constructible<T, StatusOr<U>&&>,
std::is_constructible<T, const StatusOr<U>&&>,
@@ -73,7 +73,7 @@ using IsConstructibleOrConvertibleFromStatusOr =
// `StatusOr<U>`.
template <typename T, typename U>
using IsConstructibleOrConvertibleOrAssignableFromStatusOr =
absl::disjunction<IsConstructibleOrConvertibleFromStatusOr<T, U>,
std::disjunction<IsConstructibleOrConvertibleFromStatusOr<T, U>,
std::is_assignable<T&, StatusOr<U>&>,
std::is_assignable<T&, const StatusOr<U>&>,
std::is_assignable<T&, StatusOr<U>&&>,
@@ -83,7 +83,7 @@ using IsConstructibleOrConvertibleOrAssignableFromStatusOr =
// when `U` is `StatusOr<V>` and `T` is constructible or convertible from `V`.
template <typename T, typename U>
struct IsDirectInitializationAmbiguous
: public absl::conditional_t<
: public std::conditional_t<
std::is_same<absl::remove_cvref_t<U>, U>::value, std::false_type,
IsDirectInitializationAmbiguous<T, absl::remove_cvref_t<U>>> {};
@@ -95,7 +95,7 @@ struct IsDirectInitializationAmbiguous<T, absl::StatusOr<V>>
// temporaries.
// REQUIRES: T and U are references.
template <typename T, typename U>
using IsReferenceConversionValid = absl::conjunction< //
using IsReferenceConversionValid = std::conjunction< //
std::is_reference<T>, std::is_reference<U>,
// The references are convertible. This checks for
// lvalue/rvalue compatibility.
@@ -108,13 +108,13 @@ using IsReferenceConversionValid = absl::conjunction< //
// Checks against the constraints of the direction initialization, i.e. when
// `StatusOr<T>::StatusOr(U&&)` should participate in overload resolution.
template <typename T, typename U>
using IsDirectInitializationValid = absl::disjunction<
using IsDirectInitializationValid = std::disjunction<
// Short circuits if T is basically U.
std::is_same<T, absl::remove_cvref_t<U>>, //
std::conditional_t<
std::is_reference_v<T>, //
IsReferenceConversionValid<T, U>,
absl::negation<absl::disjunction<
std::negation<std::disjunction<
std::is_same<absl::StatusOr<T>, absl::remove_cvref_t<U>>,
std::is_same<absl::Status, absl::remove_cvref_t<U>>,
std::is_same<absl::in_place_t, absl::remove_cvref_t<U>>,
@@ -132,7 +132,7 @@ using IsDirectInitializationValid = absl::disjunction<
// s1 = s2; // ambiguous, `s1 = s2.ValueOrDie()` or `s1 = bool(s2)`?
template <typename T, typename U>
struct IsForwardingAssignmentAmbiguous
: public absl::conditional_t<
: public std::conditional_t<
std::is_same<absl::remove_cvref_t<U>, U>::value, std::false_type,
IsForwardingAssignmentAmbiguous<T, absl::remove_cvref_t<U>>> {};
@@ -143,91 +143,91 @@ struct IsForwardingAssignmentAmbiguous<T, absl::StatusOr<U>>
// Checks against the constraints of the forwarding assignment, i.e. whether
// `StatusOr<T>::operator(U&&)` should participate in overload resolution.
template <typename T, typename U>
using IsForwardingAssignmentValid = absl::disjunction<
using IsForwardingAssignmentValid = std::disjunction<
// Short circuits if T is basically U.
std::is_same<T, absl::remove_cvref_t<U>>,
absl::negation<absl::disjunction<
std::negation<std::disjunction<
std::is_same<absl::StatusOr<T>, absl::remove_cvref_t<U>>,
std::is_same<absl::Status, absl::remove_cvref_t<U>>,
std::is_same<absl::in_place_t, absl::remove_cvref_t<U>>,
IsForwardingAssignmentAmbiguous<T, U>>>>;
template <bool Value, typename T>
using Equality = std::conditional_t<Value, T, absl::negation<T>>;
using Equality = std::conditional_t<Value, T, std::negation<T>>;
template <bool Explicit, typename T, typename U, bool Lifetimebound>
using IsConstructionValid = absl::conjunction<
using IsConstructionValid = std::conjunction<
Equality<Lifetimebound,
absl::disjunction<
std::disjunction<
std::is_reference<T>,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>>,
IsDirectInitializationValid<T, U&&>, std::is_constructible<T, U&&>,
Equality<!Explicit, std::is_convertible<U&&, T>>,
absl::disjunction<
std::disjunction<
std::is_same<T, absl::remove_cvref_t<U>>,
absl::conjunction<
std::conjunction<
std::conditional_t<
Explicit,
absl::negation<std::is_constructible<absl::Status, U&&>>,
absl::negation<std::is_convertible<U&&, absl::Status>>>,
absl::negation<
std::negation<std::is_constructible<absl::Status, U&&>>,
std::negation<std::is_convertible<U&&, absl::Status>>>,
std::negation<
internal_statusor::HasConversionOperatorToStatusOr<T, U&&>>>>>;
template <typename T, typename U, bool Lifetimebound>
using IsAssignmentValid = absl::conjunction<
using IsAssignmentValid = std::conjunction<
Equality<Lifetimebound,
absl::disjunction<
std::disjunction<
std::is_reference<T>,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>>,
std::conditional_t<std::is_reference_v<T>,
IsReferenceConversionValid<T, U&&>,
absl::conjunction<std::is_constructible<T, U&&>,
std::conjunction<std::is_constructible<T, U&&>,
std::is_assignable<T&, U&&>>>,
absl::disjunction<
std::disjunction<
std::is_same<T, absl::remove_cvref_t<U>>,
absl::conjunction<
absl::negation<std::is_convertible<U&&, absl::Status>>,
absl::negation<HasConversionOperatorToStatusOr<T, U&&>>>>,
std::conjunction<
std::negation<std::is_convertible<U&&, absl::Status>>,
std::negation<HasConversionOperatorToStatusOr<T, U&&>>>>,
IsForwardingAssignmentValid<T, U&&>>;
template <bool Explicit, typename T, typename U>
using IsConstructionFromStatusValid = absl::conjunction<
absl::negation<std::is_same<absl::StatusOr<T>, absl::remove_cvref_t<U>>>,
absl::negation<std::is_same<T, absl::remove_cvref_t<U>>>,
absl::negation<std::is_same<absl::in_place_t, absl::remove_cvref_t<U>>>,
using IsConstructionFromStatusValid = std::conjunction<
std::negation<std::is_same<absl::StatusOr<T>, absl::remove_cvref_t<U>>>,
std::negation<std::is_same<T, absl::remove_cvref_t<U>>>,
std::negation<std::is_same<absl::in_place_t, absl::remove_cvref_t<U>>>,
Equality<!Explicit, std::is_convertible<U, absl::Status>>,
std::is_constructible<absl::Status, U>,
absl::negation<HasConversionOperatorToStatusOr<T, U>>>;
std::negation<HasConversionOperatorToStatusOr<T, U>>>;
template <bool Explicit, typename T, typename U, bool Lifetimebound,
typename UQ>
using IsConstructionFromStatusOrValid = absl::conjunction<
absl::negation<std::is_same<T, U>>,
using IsConstructionFromStatusOrValid = std::conjunction<
std::negation<std::is_same<T, U>>,
// If `T` is a reference, then U must be a compatible one.
absl::disjunction<absl::negation<std::is_reference<T>>,
std::disjunction<std::negation<std::is_reference<T>>,
IsReferenceConversionValid<T, U>>,
Equality<Lifetimebound,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>,
std::is_constructible<T, UQ>,
Equality<!Explicit, std::is_convertible<UQ, T>>,
absl::negation<IsConstructibleOrConvertibleFromStatusOr<T, U>>>;
std::negation<IsConstructibleOrConvertibleFromStatusOr<T, U>>>;
template <typename T, typename U, bool Lifetimebound>
using IsStatusOrAssignmentValid = absl::conjunction<
absl::negation<std::is_same<T, absl::remove_cvref_t<U>>>,
using IsStatusOrAssignmentValid = std::conjunction<
std::negation<std::is_same<T, absl::remove_cvref_t<U>>>,
Equality<Lifetimebound,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>,
std::is_constructible<T, U>, std::is_assignable<T, U>,
absl::negation<IsConstructibleOrConvertibleOrAssignableFromStatusOr<
std::negation<IsConstructibleOrConvertibleOrAssignableFromStatusOr<
T, absl::remove_cvref_t<U>>>>;
template <typename T, typename U, bool Lifetimebound>
using IsValueOrValid = absl::conjunction<
using IsValueOrValid = std::conjunction<
// If `T` is a reference, then U must be a compatible one.
absl::disjunction<absl::negation<std::is_reference<T>>,
std::disjunction<std::negation<std::is_reference<T>>,
IsReferenceConversionValid<T, U>>,
Equality<Lifetimebound,
absl::disjunction<
std::disjunction<
std::is_reference<T>,
type_traits_internal::IsLifetimeBoundAssignment<T, U>>>>;
@@ -331,7 +331,7 @@ class StatusOrData {
}
template <typename U,
absl::enable_if_t<std::is_constructible<absl::Status, U&&>::value,
std::enable_if_t<std::is_constructible<absl::Status, U&&>::value,
int> = 0>
explicit StatusOrData(U&& v) : status_(std::forward<U>(v)) {
EnsureNotOk();

View File

@@ -247,50 +247,50 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
// is explicit if and only if the corresponding construction of `T` from `U`
// is explicit. (This constructor inherits its explicitness from the
// underlying constructor.)
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, false, const U&>::value,
int> = 0>
StatusOr(const StatusOr<U>& other) // NOLINT
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, true, const U&>::value,
int> = 0>
StatusOr(const StatusOr<U>& other ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, false, const U&>::value,
int> = 0>
explicit StatusOr(const StatusOr<U>& other)
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, true, const U&>::value,
int> = 0>
explicit StatusOr(const StatusOr<U>& other ABSL_ATTRIBUTE_LIFETIME_BOUND)
: Base(static_cast<const typename StatusOr<U>::Base&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, false, U&&>::value,
int> = 0>
StatusOr(StatusOr<U>&& other) // NOLINT
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
false, T, U, true, U&&>::value,
int> = 0>
StatusOr(StatusOr<U>&& other ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, false, U&&>::value,
int> = 0>
explicit StatusOr(StatusOr<U>&& other)
: Base(static_cast<typename StatusOr<U>::Base&&>(other)) {}
template <typename U, absl::enable_if_t<
template <typename U, std::enable_if_t<
internal_statusor::IsConstructionFromStatusOrValid<
true, T, U, true, U&&>::value,
int> = 0>
@@ -317,7 +317,7 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
// assignable from `absl::StatusOr<U>` and `StatusOr<T>` cannot be directly
// assigned from `StatusOr<U>`.
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
std::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, const U&, false>::value,
int> = 0>
StatusOr& operator=(const StatusOr<U>& other) {
@@ -325,7 +325,7 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
return *this;
}
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
std::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, const U&, true>::value,
int> = 0>
StatusOr& operator=(const StatusOr<U>& other ABSL_ATTRIBUTE_LIFETIME_BOUND) {
@@ -333,7 +333,7 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
return *this;
}
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
std::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, U&&, false>::value,
int> = 0>
StatusOr& operator=(StatusOr<U>&& other) {
@@ -341,7 +341,7 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
return *this;
}
template <typename U,
absl::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
std::enable_if_t<internal_statusor::IsStatusOrAssignmentValid<
T, U&&, true>::value,
int> = 0>
StatusOr& operator=(StatusOr<U>&& other ABSL_ATTRIBUTE_LIFETIME_BOUND) {
@@ -361,18 +361,18 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
// In optimized builds, passing absl::OkStatus() here will have the effect
// of passing absl::StatusCode::kInternal as a fallback.
template <typename U = absl::Status,
absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
std::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
false, T, U>::value,
int> = 0>
StatusOr(U&& v) : Base(std::forward<U>(v)) {}
template <typename U = absl::Status,
absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
std::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
true, T, U>::value,
int> = 0>
explicit StatusOr(U&& v) : Base(std::forward<U>(v)) {}
template <typename U = absl::Status,
absl::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
std::enable_if_t<internal_statusor::IsConstructionFromStatusValid<
false, T, U>::value,
int> = 0>
StatusOr& operator=(U&& v) {
@@ -429,26 +429,26 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
// ambiguity, this constructor is disabled if `U` is a `StatusOr<J>`, where
// `J` is convertible to `T`.
template <typename U = T,
absl::enable_if_t<internal_statusor::IsConstructionValid<
std::enable_if_t<internal_statusor::IsConstructionValid<
false, T, U, false>::value,
int> = 0>
StatusOr(U&& u) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
template <typename U = T,
absl::enable_if_t<internal_statusor::IsConstructionValid<
std::enable_if_t<internal_statusor::IsConstructionValid<
false, T, U, true>::value,
int> = 0>
StatusOr(U&& u ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
template <typename U = T,
absl::enable_if_t<internal_statusor::IsConstructionValid<
std::enable_if_t<internal_statusor::IsConstructionValid<
true, T, U, false>::value,
int> = 0>
explicit StatusOr(U&& u) // NOLINT
: StatusOr(absl::in_place, std::forward<U>(u)) {}
template <typename U = T,
absl::enable_if_t<
std::enable_if_t<
internal_statusor::IsConstructionValid<true, T, U, true>::value,
int> = 0>
explicit StatusOr(U&& u ABSL_ATTRIBUTE_LIFETIME_BOUND) // NOLINT
@@ -624,7 +624,7 @@ class StatusOr : private internal_statusor::OperatorBase<T>,
template <
typename U, typename... Args,
absl::enable_if_t<
std::enable_if_t<
std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value,
int> = 0>
T& emplace(std::initializer_list<U> ilist,

View File

@@ -401,7 +401,6 @@ cc_test(
visibility = ["//visibility:private"],
deps = [
":strings",
"//absl/meta:type_traits",
"@googletest//:gtest",
"@googletest//:gtest_main",
],

View File

@@ -339,7 +339,6 @@ absl_cc_test(
${ABSL_TEST_COPTS}
DEPS
absl::strings
absl::type_traits
GTest::gmock_main
)

View File

@@ -174,7 +174,7 @@ class Cord {
private:
template <typename T>
using EnableIfString =
absl::enable_if_t<std::is_same<T, std::string>::value, int>;
std::enable_if_t<std::is_same<T, std::string>::value, int>;
public:
// Cord::Cord() Constructors.
@@ -1137,7 +1137,7 @@ template <typename Releaser>
CordRep* absl_nonnull NewExternalRep(absl::string_view data,
Releaser&& releaser) {
assert(!data.empty());
using ReleaserType = absl::decay_t<Releaser>;
using ReleaserType = std::decay_t<Releaser>;
CordRepExternal* rep = new CordRepExternalImpl<ReleaserType>(
std::forward<Releaser>(releaser), 0);
InitializeCordRepExternal(data, rep);
@@ -1162,7 +1162,7 @@ Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser) {
data, std::forward<Releaser>(releaser)),
Cord::MethodIdentifier::kMakeCordFromExternal);
} else {
using ReleaserType = absl::decay_t<Releaser>;
using ReleaserType = std::decay_t<Releaser>;
cord_internal::InvokeReleaser(
cord_internal::Rank1{}, ReleaserType(std::forward<Releaser>(releaser)),
data);

View File

@@ -48,25 +48,25 @@ struct IsSpecializationImpl : std::false_type {};
template <template <typename...> class T, typename... Args>
struct IsSpecializationImpl<T<Args...>, T> : std::true_type {};
template <typename C, template <typename...> class T>
using IsSpecialization = IsSpecializationImpl<absl::decay_t<C>, T>;
using IsSpecialization = IsSpecializationImpl<std::decay_t<C>, T>;
template <typename C>
struct IsArrayImpl : std::false_type {};
template <template <typename, size_t> class A, typename T, size_t N>
struct IsArrayImpl<A<T, N>> : std::is_same<A<T, N>, std::array<T, N>> {};
template <typename C>
using IsArray = IsArrayImpl<absl::decay_t<C>>;
using IsArray = IsArrayImpl<std::decay_t<C>>;
template <typename C>
struct IsBitsetImpl : std::false_type {};
template <template <size_t> class B, size_t N>
struct IsBitsetImpl<B<N>> : std::is_same<B<N>, std::bitset<N>> {};
template <typename C>
using IsBitset = IsBitsetImpl<absl::decay_t<C>>;
using IsBitset = IsBitsetImpl<std::decay_t<C>>;
template <typename C>
struct IsSTLContainer
: absl::disjunction<
: std::disjunction<
IsArray<C>, IsBitset<C>, IsSpecialization<C, std::deque>,
IsSpecialization<C, std::forward_list>,
IsSpecialization<C, std::list>, IsSpecialization<C, std::map>,
@@ -123,7 +123,7 @@ struct IsBaseOfSpecializationImpl<
typename C::hasher, typename C::key_equal,
typename C::allocator_type>> {};
template <typename C, template <typename...> class T>
using IsBaseOfSpecialization = IsBaseOfSpecializationImpl<absl::decay_t<C>, T>;
using IsBaseOfSpecialization = IsBaseOfSpecializationImpl<std::decay_t<C>, T>;
template <typename C>
struct IsBaseOfArrayImpl : std::false_type {};
@@ -131,18 +131,18 @@ template <template <typename, size_t> class A, typename T, size_t N>
struct IsBaseOfArrayImpl<A<T, N>> : std::is_base_of<A<T, N>, std::array<T, N>> {
};
template <typename C>
using IsBaseOfArray = IsBaseOfArrayImpl<absl::decay_t<C>>;
using IsBaseOfArray = IsBaseOfArrayImpl<std::decay_t<C>>;
template <typename C>
struct IsBaseOfBitsetImpl : std::false_type {};
template <template <size_t> class B, size_t N>
struct IsBaseOfBitsetImpl<B<N>> : std::is_base_of<B<N>, std::bitset<N>> {};
template <typename C>
using IsBaseOfBitset = IsBaseOfBitsetImpl<absl::decay_t<C>>;
using IsBaseOfBitset = IsBaseOfBitsetImpl<std::decay_t<C>>;
template <typename C>
struct IsBaseOfSTLContainer
: absl::disjunction<IsBaseOfArray<C>, IsBaseOfBitset<C>,
: std::disjunction<IsBaseOfArray<C>, IsBaseOfBitset<C>,
IsBaseOfSpecialization<C, std::deque>,
IsBaseOfSpecialization<C, std::forward_list>,
IsBaseOfSpecialization<C, std::list>,
@@ -201,7 +201,7 @@ struct IsConvertibleToSpecializationImpl<
typename C::allocator_type>> {};
template <typename C, template <typename...> class T>
using IsConvertibleToSpecialization =
IsConvertibleToSpecializationImpl<absl::decay_t<C>, T>;
IsConvertibleToSpecializationImpl<std::decay_t<C>, T>;
template <typename C>
struct IsConvertibleToArrayImpl : std::false_type {};
@@ -209,7 +209,7 @@ template <template <typename, size_t> class A, typename T, size_t N>
struct IsConvertibleToArrayImpl<A<T, N>>
: std::is_convertible<A<T, N>, std::array<T, N>> {};
template <typename C>
using IsConvertibleToArray = IsConvertibleToArrayImpl<absl::decay_t<C>>;
using IsConvertibleToArray = IsConvertibleToArrayImpl<std::decay_t<C>>;
template <typename C>
struct IsConvertibleToBitsetImpl : std::false_type {};
@@ -217,11 +217,11 @@ template <template <size_t> class B, size_t N>
struct IsConvertibleToBitsetImpl<B<N>>
: std::is_convertible<B<N>, std::bitset<N>> {};
template <typename C>
using IsConvertibleToBitset = IsConvertibleToBitsetImpl<absl::decay_t<C>>;
using IsConvertibleToBitset = IsConvertibleToBitsetImpl<std::decay_t<C>>;
template <typename C>
struct IsConvertibleToSTLContainer
: absl::disjunction<
: std::disjunction<
IsConvertibleToArray<C>, IsConvertibleToBitset<C>,
IsConvertibleToSpecialization<C, std::deque>,
IsConvertibleToSpecialization<C, std::forward_list>,
@@ -238,7 +238,7 @@ struct IsConvertibleToSTLContainer
template <typename C>
struct IsStrictlyBaseOfAndConvertibleToSTLContainer
: absl::conjunction<absl::negation<IsSTLContainer<C>>,
: std::conjunction<std::negation<IsSTLContainer<C>>,
IsBaseOfSTLContainer<C>,
IsConvertibleToSTLContainer<C>> {};

View File

@@ -133,9 +133,9 @@ auto FormatConvertImpl(const T& v, FormatConversionSpecImpl conv,
std::declval<const FormatConversionSpec&>(),
std::declval<FormatSink*>())) {
using FormatConversionSpecT =
absl::enable_if_t<sizeof(const T& (*)()) != 0, FormatConversionSpec>;
std::enable_if_t<sizeof(const T& (*)()) != 0, FormatConversionSpec>;
using FormatSinkT =
absl::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>;
std::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>;
auto fcs = conv.Wrap<FormatConversionSpecT>();
auto fs = sink->Wrap<FormatSinkT>();
return AbslFormatConvert(v, fcs, &fs);
@@ -150,7 +150,7 @@ auto FormatConvertImpl(const T& v, FormatConversionSpecImpl conv,
IntegralConvertResult> {
if (conv.conversion_char() == FormatConversionCharInternal::v) {
using FormatSinkT =
absl::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>;
std::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>;
auto fs = sink->Wrap<FormatSinkT>();
AbslStringify(fs, v);
return {true};
@@ -169,7 +169,7 @@ auto FormatConvertImpl(const T& v, FormatConversionSpecImpl,
std::declval<FormatSink&>(), v))>::value,
ArgConvertResult<FormatConversionCharSetInternal::v>> {
using FormatSinkT =
absl::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>;
std::enable_if_t<sizeof(const T& (*)()) != 0, FormatSink>;
auto fs = sink->Wrap<FormatSinkT>();
AbslStringify(fs, v);
return {true};
@@ -381,7 +381,7 @@ struct FormatCountCaptureHelper {
static ArgConvertResult<FormatConversionCharSetInternal::n> ConvertHelper(
const FormatCountCapture& v, FormatConversionSpecImpl conv,
FormatSinkImpl* sink) {
const absl::enable_if_t<sizeof(T) != 0, FormatCountCapture>& v2 = v;
const std::enable_if_t<sizeof(T) != 0, FormatCountCapture>& v2 = v;
if (conv.conversion_char() !=
str_format_internal::FormatConversionCharInternal::n) {

View File

@@ -25,6 +25,7 @@
#include <limits>
#include <optional>
#include <string>
#include <type_traits>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
@@ -100,7 +101,7 @@ class StackArray {
// Requires: `0 <= carry <= 9`
template <typename Int>
inline char MultiplyBy10WithCarry(Int* v, char carry) {
using BiggerInt = absl::conditional_t<sizeof(Int) == 4, uint64_t, uint128>;
using BiggerInt = std::conditional_t<sizeof(Int) == 4, uint64_t, uint128>;
BiggerInt tmp =
10 * static_cast<BiggerInt>(*v) + static_cast<BiggerInt>(carry);
*v = static_cast<Int>(tmp);
@@ -1184,8 +1185,8 @@ constexpr bool CanFitMantissa() {
template <typename Float>
struct Decomposed {
using MantissaType =
absl::conditional_t<std::is_same<long double, Float>::value, uint128,
uint64_t>;
std::conditional_t<std::is_same<long double, Float>::value, uint128,
uint64_t>;
static_assert(std::numeric_limits<Float>::digits <= sizeof(MantissaType) * 8,
"");
MantissaType mantissa;

View File

@@ -224,7 +224,7 @@ struct SplitterIsConvertibleToImpl<C, true, false>
template <typename C>
struct SplitterIsConvertibleToImpl<C, true, true>
: absl::conjunction<
: std::conjunction<
std::is_constructible<typename C::key_type, absl::string_view>,
std::is_constructible<typename C::mapped_type, absl::string_view>> {};
@@ -494,7 +494,7 @@ class Splitter {
// Inserts the key and an empty value into the map, returning an iterator to
// the inserted item. We use emplace() if available, otherwise insert().
template <typename M>
static absl::enable_if_t<HasEmplace<M>::value, iterator> InsertOrEmplace(
static std::enable_if_t<HasEmplace<M>::value, iterator> InsertOrEmplace(
M* m, absl::string_view key) {
// Use piecewise_construct to support old versions of gcc in which pair
// constructor can't otherwise construct string from string_view.
@@ -502,7 +502,7 @@ class Splitter {
std::tuple<>()));
}
template <typename M>
static absl::enable_if_t<!HasEmplace<M>::value, iterator> InsertOrEmplace(
static std::enable_if_t<!HasEmplace<M>::value, iterator> InsertOrEmplace(
M* m, absl::string_view key) {
return ToIter(m->insert(std::make_pair(First(key), Second(""))));
}

View File

@@ -14,7 +14,8 @@
#include "absl/strings/internal/string_constant.h"
#include "absl/meta/type_traits.h"
#include <type_traits>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -34,10 +35,10 @@ TEST(StringConstant, Traits) {
EXPECT_TRUE(std::is_empty<T>::value);
EXPECT_TRUE(std::is_trivial<T>::value);
EXPECT_TRUE(absl::is_trivially_default_constructible<T>::value);
EXPECT_TRUE(absl::is_trivially_copy_constructible<T>::value);
EXPECT_TRUE(absl::is_trivially_move_constructible<T>::value);
EXPECT_TRUE(absl::is_trivially_destructible<T>::value);
EXPECT_TRUE(std::is_trivially_default_constructible<T>::value);
EXPECT_TRUE(std::is_trivially_copy_constructible<T>::value);
EXPECT_TRUE(std::is_trivially_move_constructible<T>::value);
EXPECT_TRUE(std::is_trivially_destructible<T>::value);
}
TEST(StringConstant, MakeFromCallable) {

View File

@@ -449,7 +449,7 @@ namespace compare_internal {
// or three-way comparator.
// SFINAE prevents implicit conversions to bool (such as from int).
template <typename BoolT,
absl::enable_if_t<std::is_same<bool, BoolT>::value, int> = 0>
std::enable_if_t<std::is_same<bool, BoolT>::value, int> = 0>
constexpr bool compare_result_as_less_than(const BoolT r) {
return r;
}
@@ -467,7 +467,7 @@ constexpr bool do_less_than_comparison(const Compare& compare, const K& x,
// three-way comparator.
// SFINAE prevents implicit conversions to int (such as from bool).
template <typename Int,
absl::enable_if_t<std::is_same<int, Int>::value, int> = 0>
std::enable_if_t<std::is_same<int, Int>::value, int> = 0>
constexpr absl::weak_ordering compare_result_as_ordering(const Int c) {
return c < 0 ? absl::weak_ordering::less
: c == 0 ? absl::weak_ordering::equivalent
@@ -479,7 +479,7 @@ constexpr absl::weak_ordering compare_result_as_ordering(
}
template <typename Compare, typename K, typename LK,
absl::enable_if_t<
std::enable_if_t<
!std::is_same<
bool, absl::result_of_t<Compare(const K&, const LK&)>>::value,
int> = 0>
@@ -488,7 +488,7 @@ constexpr absl::weak_ordering do_three_way_comparison(const Compare& compare,
return compare_result_as_ordering(compare(x, y));
}
template <typename Compare, typename K, typename LK,
absl::enable_if_t<
std::enable_if_t<
std::is_same<
bool, absl::result_of_t<Compare(const K&, const LK&)>>::value,
int> = 0>

View File

@@ -152,7 +152,7 @@ T& ApplyTransform(TransformPtr transform, U& u) { // NOLINT(runtime/references)
// references to support mutable -> const conversion of spans without additional
// indirection.
template <typename T>
using GetterFunctionResult = absl::remove_const_t<T>&;
using GetterFunctionResult = std::remove_const_t<T>&;
// A type of function pointer that can return an element of a
// TransformedContainer. This is used so that we can type-erase with a simple
@@ -262,8 +262,8 @@ struct Getter {
// Handle mutable -> const conversion.
template <typename LazyT = T, typename = typename std::enable_if<
std::is_const<LazyT>::value>::type>
explicit Getter(const Getter<absl::remove_const_t<T>>& other) {
using MutableT = absl::remove_const_t<T>;
explicit Getter(const Getter<std::remove_const_t<T>>& other) {
using MutableT = std::remove_const_t<T>;
if (other.fun == &ArrayTag<MutableT>) {
ABSL_RAW_DCHECK(other.offset == 0u, "offset must be zero");
fun = &ArrayTag<T>;

View File

@@ -54,7 +54,7 @@ constexpr auto GetData(C& c) noexcept // NOLINT(runtime/references)
// Detection idioms for size() and data().
template <typename C>
using HasSize =
std::is_integral<absl::decay_t<decltype(std::declval<C&>().size())>>;
std::is_integral<std::decay_t<decltype(std::declval<C&>().size())>>;
// We want to enable conversion from vector<T*> to Span<const T* const> but
// disable conversion from vector<Derived> to Span<Base>. Here we use
@@ -64,13 +64,13 @@ using HasSize =
// which returns a reference.
template <typename T, typename C>
using HasData =
std::is_convertible<absl::decay_t<decltype(GetData(std::declval<C&>()))>*,
std::is_convertible<std::decay_t<decltype(GetData(std::declval<C&>()))>*,
T* const*>;
// Extracts value type from a Container
template <typename C>
struct ElementType {
using type = typename absl::remove_reference_t<C>::value_type;
using type = typename std::remove_reference_t<C>::value_type;
};
template <typename T, size_t N>

View File

@@ -204,7 +204,7 @@ class ABSL_ATTRIBUTE_VIEW Span {
public:
using element_type = T;
using value_type = absl::remove_cv_t<T>;
using value_type = std::remove_cv_t<T>;
// TODO(b/316099902) - pointer should be absl_nullable, but this makes it hard
// to recognize foreach loops as safe. absl_nullability_unknown is currently
// used to suppress -Wnullability-completeness warnings.