Skip to content

Commit

Permalink
fix clang bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wjr-z committed Jun 28, 2024
1 parent 8b789c8 commit 592645c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions godbolt/wjr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7046,6 +7046,10 @@ struct __inserter_container_accessor : Iter {
using Iter::container;
};

/// @private
template <typename Iter>
__inserter_container_accessor(Iter) -> __inserter_container_accessor<Iter>;

/// @private
template <typename Iter>
struct __inserter_iterator_accessor : Iter {
Expand All @@ -7055,29 +7059,36 @@ struct __inserter_iterator_accessor : Iter {
using Iter::iter;
};

template <typename Iter>
__inserter_iterator_accessor(Iter) -> __inserter_iterator_accessor<Iter>;

template <typename Container>
Container &get_inserter_container(std::insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::insert_iterator<Container>>) {
return *(__inserter_container_accessor(it).container);
__inserter_container_accessor tmp(it);
return *(tmp.container);
}

template <typename Container>
Container &get_inserter_container(std::back_insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::back_insert_iterator<Container>>) {
return *(__inserter_container_accessor(it).container);
__inserter_container_accessor tmp(it);
return *(tmp.container);
}

template <typename Container>
Container &get_inserter_container(std::front_insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::front_insert_iterator<Container>>) {
return *(__inserter_container_accessor(it).container);
__inserter_container_accessor tmp(it);
return *(tmp.container);
}

template <typename Container>
typename Container::iterator
get_inserter_iterator(std::insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::insert_iterator<Container>>) {
return __inserter_iterator_accessor(it).iter;
__inserter_iterator_accessor tmp(it);
return *(tmp.iter);
}

} // namespace wjr
Expand Down
19 changes: 15 additions & 4 deletions include/wjr/iterator/inserter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ struct __inserter_container_accessor : Iter {
using Iter::container;
};

/// @private
template <typename Iter>
__inserter_container_accessor(Iter) -> __inserter_container_accessor<Iter>;

/// @private
template <typename Iter>
struct __inserter_iterator_accessor : Iter {
Expand All @@ -59,29 +63,36 @@ struct __inserter_iterator_accessor : Iter {
using Iter::iter;
};

template <typename Iter>
__inserter_iterator_accessor(Iter) -> __inserter_iterator_accessor<Iter>;

template <typename Container>
Container &get_inserter_container(std::insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::insert_iterator<Container>>) {
return *(__inserter_container_accessor(it).container);
__inserter_container_accessor tmp(it);
return *(tmp.container);
}

template <typename Container>
Container &get_inserter_container(std::back_insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::back_insert_iterator<Container>>) {
return *(__inserter_container_accessor(it).container);
__inserter_container_accessor tmp(it);
return *(tmp.container);
}

template <typename Container>
Container &get_inserter_container(std::front_insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::front_insert_iterator<Container>>) {
return *(__inserter_container_accessor(it).container);
__inserter_container_accessor tmp(it);
return *(tmp.container);
}

template <typename Container>
typename Container::iterator
get_inserter_iterator(std::insert_iterator<Container> it) noexcept(
std::is_nothrow_copy_constructible_v<std::insert_iterator<Container>>) {
return __inserter_iterator_accessor(it).iter;
__inserter_iterator_accessor tmp(it);
return *(tmp.iter);
}

} // namespace wjr
Expand Down

0 comments on commit 592645c

Please sign in to comment.