argument-dependent-lookup Questions
1
Solved
I have a simple code with inheritance and shared_ptr from boost library. With standard c++20, the code compiles fine. The function calls to static_pointer_cast and dynamic_pointer_cast compiles wit...
Hydroxide asked 24/6, 2022 at 18:7
1
Solved
Otherwise, size(t) converted to its decayed type, if ranges::disable_sized_range<std::remove_cv_t<T>> is false, and the converted expression is valid and has an integer-like type, wher...
Tecla asked 8/6, 2022 at 15:49
1
Solved
According to the standard, friend function declared and defined in class can only be find by ADL. So, I think the following code should compile.
template<int M>
struct test{
template<int...
Photoluminescence asked 20/6, 2016 at 2:19
1
Solved
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>();
...
Actually asked 27/5, 2021 at 7:26
3
Solved
I was trying to learn and adopt the copy-swap idiom following this thorough explanation on this question: the Copy-Swap Idiom.
But I found some code I had never seen: using std::swap; // all...
Buxtehude asked 24/1, 2011 at 13:44
1
Solved
The program as follows compiles fine in C++20:
#include <memory>
struct A{ virtual ~A() = default; };
struct B: A {};
int main()
{
std::shared_ptr<A> p = std::make_shared<B>();...
Twitch asked 14/6, 2021 at 18:42
2
Solved
Can anybody explain why there is an ambiguity between A::f(const B& b) and f(const A::B& b). I consider the code to be quite explicit about the intention.
#include <iostream>
namespa...
Gunar asked 5/5, 2021 at 8:13
3
Solved
I have a set of templates/functions that allow me to print a tuple/pair assuming that each type in the tuple/pair has operator<< defined for it. Unfortunately, due to 17.4.3.1, it is illegal ...
Freyah asked 22/2, 2011 at 9:16
1
Solved
Consider the following example:
namespace N {
template<class>
struct C { };
template<int, class T>
void foo(C<T>);
}
template<class T>
void bar(N::C<T> c) {
foo...
Harquebus asked 9/12, 2020 at 21:27
2
Solved
As an example, I want to use a constraint to ensure that the function isinf is implemented for a template parameter T. If T is one of float, double, long double or an integral type, this can be don...
Braunite asked 7/11, 2020 at 0:23
2
Solved
Actually, the below code can not be compiled with Clang using this command:
clang++ -std=c++11 test.cc -o test.
I just want to mimic the same behavior as "swapping idiom" in C++ to use &q...
Ragan asked 20/8, 2020 at 6:12
2
Solved
In his recent blog post Anthony Williams talks about hidden friends. The main idea, if I understood it correctly, is that functions declared as friends cannot be found by ADL in certain situations....
Toilworn asked 27/6, 2019 at 16:57
3
Solved
The situation is that some member function bar::Bar::frobnicate wants to utilize ADL to find a function from some unknown namespace, within a function that has an identical name. However, it only f...
Benedicto asked 24/7, 2013 at 6:1
1
Solved
TL;DR
Before you attempt to read this whole post, know that:
a solution to the presented issue has been found by myself, but I'm still eager to know if the analysis is correct;
I've packaged the s...
Kapp asked 5/2, 2020 at 18:46
1
Solved
This description on cppreference.com says that
The lookup of a dependent name used in a template is postponed until the template arguments are known, at which time [...] ADL examines function de...
Shewchuk asked 26/8, 2019 at 18:33
1
The following code compiles with MSVC and gcc, but not with clang. Why is that so?
It seems like if ADL would not work if CallFoo () is constexpr. See the comment.
template <class T>
conste...
Intuitional asked 14/8, 2019 at 21:1
1
Solved
Consider the following code snippet:
#include <functional>
namespace ns {
struct Arg{};
using Func = std::function<int(Arg)>;
Func operator+(Func lhs, Func rhs) {
return [lhs, rh...
Oversold asked 14/8, 2019 at 14:17
2
Solved
I stumbled on this the other day and can't figure out which answer is correct, or whether both are acceptable.
Specifically, I'm referring to the call to bar(T{}) in OtherFunction. From what I've...
Uncinate asked 8/6, 2019 at 1:3
7
Solved
In a generic function I use the following idiom,
template<class It1, class It2>
void do_something(It1 first, It1 second, It2 d_first){
... other stuff here...
using std::copy;
copy(first,...
Chromophore asked 28/1, 2019 at 11:13
4
Solved
What part of the C++ specification restricts argument dependent lookup from finding function templates in the set of associated namespaces? In other words, why does the last call in main below fail...
Mima asked 1/6, 2010 at 22:0
1
Solved
If I have a normal class I can "inject" a non-free friend function inside the class. (That among other things can be only be found by ADL).
case 1:
class A{
double p_;
friend double f(A const&a...
Mainsheet asked 10/10, 2018 at 21:46
1
Solved
Does anybody know why the next piece of code isn't compiled on Clang 4.0.1?
I have the next error:
call to function 'operator<<' that is neither visible in the template
definition ...
Kyrstin asked 3/10, 2018 at 14:52
2
Solved
Consider this code sample
template <typename T> struct S { T t; };
template <class T> void foo(const S<T> &v)
{
bar(v.t);
}
namespace N
{
struct A {};
}
void bar(const ...
Moppet asked 27/9, 2018 at 17:29
2
Solved
I'm trying to define an equality operator for a type T defined in another namespace, and then use the equality operator on optional<T>. On clang (Apple LLVM 9.1.0), this code:
namespace nsp...
Kamila asked 21/8, 2018 at 14:41
2
In the following code
template <typename T>
void foo(T) {
bar(T{});
}
class Something {};
void bar(Something) {}
int main() {
foo(Something{});
}
(https://wandbox.org/permlink/l2hxdZo...
Unpen asked 18/8, 2018 at 5:21
1 Next >
© 2022 - 2024 — McMap. All rights reserved.