Category : argument-dependent-lookup

I’m trying to use a concept that applies to both built-in and user-defined types. In my setting, it is inconvenient to forward-declare certain functions (because the functions depend indirectly on the concepts causing my problem). My problem is that concepts don’t recognize functions that were not previously declared if those functions have arguments of built-in ..

Read more

Consider // https://godbolt.org/z/z5M9b9jzx #include <memory> #include <cassert> struct B {}; struct D : B {}; int main() { std::shared_ptr<B> b = std::make_shared<D>(); auto d = static_pointer_cast<D>(b); assert(d); } I’d’ve expected the unqualified call to static_pointer_cast to resolve to std::static_pointer_cast, because b, being a std::shared_ptr, should bring namespace std in using ADL. Why doesn’t it? I ..

Read more

I implement a function named make_heap() in namespace dsa. and I get error when I tried to invoke it and std::make_heap() to make comparison. GCC told me that: call of overloaded ‘make_heap(dsa::Vector::iterator&, dsa::Vector::iterator&, std::greater)’ is ambiguous The code is following, any suggestions? template<typename _Random_It> void make_heap(_Random_It first, _Random_It last) { // get true value_type from ..

Read more

If I have a structure the overloads begin, end, etc. like the following: #include <array> template<typename T> struct Array10 { private: std::array<T, 10> m_array; public: constexpr auto begin() { return std::begin(m_array); // #1 } constexpr auto end() { return std::end(m_array); } // cbegin, cend, rbegin, rend, crbegin, crend }; int main() { Array10<int> arr; std::fill( ..

Read more