Skip to content

Commit

Permalink
Use std::to_address if available (#1002)
Browse files Browse the repository at this point in the history
Prevents 
```
common/alspan.h:105:57: error: call to 'to_address' is ambiguous
    constexpr explicit span(U iter, index_type) : mData{to_address(iter)} { }
```

when `std::to_address` can be found via ADL.
  • Loading branch information
georgthegreat committed Jun 9, 2024
1 parent f21e916 commit 5916ec1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/almalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ constexpr bool operator!=(const allocator<T,N>&, const allocator<U,M>&) noexcept
{ return allocator<T,N>::Alignment != allocator<U,M>::Alignment; }


#ifdef __cpp_lib_to_address
using std::to_address;
#else
template<typename T>
constexpr T *to_address(T *p) noexcept
{
Expand All @@ -100,7 +103,7 @@ constexpr auto to_address(const T &p) noexcept
{
return ::al::to_address(p.operator->());
}

#endif

template<typename T, typename ...Args>
constexpr T* construct_at(T *ptr, Args&& ...args)
Expand Down

0 comments on commit 5916ec1

Please sign in to comment.