Skip to content

Commit 5afcd09

Browse files
committed
Potentially improve compile times by using a class templated on only the output iterator, rather than a lambda that depends on two template parameters. This also works around a clang bug.
1 parent ac8273f commit 5afcd09

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

source/containers/algorithms/uninitialized.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,24 @@ concept memcpyable =
3434
std::same_as<range_value_t<InputRange>, iter_value_t<OutputIterator>> and
3535
std::is_trivially_copyable_v<iter_value_t<OutputIterator>>;
3636

37+
template<typename Iterator>
38+
struct construct_at_output {
39+
explicit constexpr construct_at_output(Iterator & output):
40+
m_output(output)
41+
{
42+
}
43+
constexpr auto operator()(auto make) const -> void {
44+
bounded::construct_at(*m_output, make);
45+
++m_output;
46+
}
47+
private:
48+
Iterator & m_output;
49+
};
50+
3751
export constexpr auto uninitialized_copy = [](range auto && input, iterator auto output) {
3852
auto out_first = output;
3953
try {
40-
copy_or_relocate_from(OPERATORS_FORWARD(input), [&](auto make) {
41-
bounded::construct_at(*output, make);
42-
++output;
43-
});
54+
copy_or_relocate_from(OPERATORS_FORWARD(input), construct_at_output(output));
4455
} catch (...) {
4556
containers::destroy_range(range_view(out_first, output));
4657
throw;

0 commit comments

Comments
 (0)