Skip to content

Commit

Permalink
Update libcxx/unord.set
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Oct 15, 2024
1 parent 530cb3c commit 28db70d
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions test/sources/libcxx/unord.set/unord.set.cnstr/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,28 @@
// template<class T, class Hash, class Allocator>
// unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator)
// -> unordered_set<T, Hash, equal_to<T>, Allocator>;
//
// template<ranges::input_range R,
// class Hash = hash<ranges::range_value_t<R>>,
// class Pred = equal_to<ranges::range_value_t<R>>,
// class Allocator = allocator<ranges::range_value_t<R>>>
// unordered_set(from_range_t, R&&, typename see below::size_type = see below, Hash = Hash(), Pred = Pred(), Allocator = Allocator())
// -> unordered_set<ranges::range_value_t<R>, Hash, Pred, Allocator>; // C++23
//
// template<ranges::input_range R, class Allocator>
// unordered_set(from_range_t, R&&, typename see below::size_type, Allocator)
// -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
// equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
//
// template<ranges::input_range R, class Allocator>
// unordered_set(from_range_t, R&&, Allocator)
// -> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
// equal_to<ranges::range_value_t<R>>, Allocator>; // C++23
//
// template<ranges::input_range R, class Hash, class Allocator>
// unordered_set(from_range_t, R&&, typename see below::size_type, Hash, Allocator)
// -> unordered_set<ranges::range_value_t<R>, Hash,
// equal_to<ranges::range_value_t<R>>, Allocator>; // C++23

int main(int, char**)
{
Expand Down Expand Up @@ -188,6 +210,58 @@ int main(int, char**)
assert(s.get_allocator().get_id() == 42);
}

#if TEST_STD_VER >= 23
{
using Range = std::array<int, 0>;
using Pred = test_equal_to<int>;
using DefaultPred = std::equal_to<int>;
using Hash = test_hash<int>;
using DefaultHash = momo::HashCoder<int>;
using Alloc = test_allocator<int>;

{ // (from_range, range)
momo::stdish::unordered_set c(std::from_range, Range());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int>>);
}

{ // (from_range, range, n)
momo::stdish::unordered_set c(std::from_range, Range(), std::size_t());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int>>);
}

{ // (from_range, range, n, hash)
momo::stdish::unordered_set c(std::from_range, Range(), std::size_t(), Hash());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int, Hash>>);
}

{ // (from_range, range, n, hash, pred)
momo::stdish::unordered_set c(std::from_range, Range(), std::size_t(), Hash(), Pred());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int, Hash, Pred>>);
}

{ // (from_range, range, n, hash, pred, alloc)
momo::stdish::unordered_set c(std::from_range, Range(), std::size_t(), Hash(), Pred(), Alloc());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int, Hash, Pred, Alloc>>);
}

{ // (from_range, range, n, alloc)
momo::stdish::unordered_set c(std::from_range, Range(), std::size_t(), Alloc());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int, DefaultHash, DefaultPred, Alloc>>);
}

// TODO(LWG 2713): uncomment this test once the constructor is added.
{ // (from_range, range, alloc)
//momo::stdish::unordered_set c(std::from_range, Range(), Alloc());
//static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int, DefaultHash, DefaultPred, Alloc>>);
}

{ // (from_range, range, n, hash, alloc)
momo::stdish::unordered_set c(std::from_range, Range(), std::size_t(), Hash(), Alloc());
static_assert(std::is_same_v<decltype(c), momo::stdish::unordered_set<int, Hash, DefaultPred, Alloc>>);
}
}
#endif

#if !(defined(TEST_MSVC) && _MSC_VER < 1930) && !(defined(TEST_GCC) && __GNUC__ < 11)
#if MOMO_VERSION_MAJOR > 3
UnorderedContainerDeductionGuidesSfinaeAway<std::unordered_set, std::unordered_set<int>>();
Expand Down

0 comments on commit 28db70d

Please sign in to comment.