argument-dependent-lookup Questions
1
Solved
Consider this code (or the live example):
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/range/iterator_range.hpp>
using std::cout;
int main() {...
Anarchism asked 1/11, 2015 at 12:10
1
Solved
This is an extension to this question from 2011:
Range-based for loops and ADL
Using Visual Studio 2015, I'm not able to make a range-based for loop for a custom container using Argument Dependent ...
Jerroldjerroll asked 20/9, 2015 at 16:30
3
Solved
This is very similar to this question, but I'm not sure the answer there is entirely applicable to the minimal code I've put together that demonstrates the issue. (My code does not use trailing-ret...
Timbuktu asked 26/8, 2015 at 20:7
2
Solved
I'm trying to create a function that takes an underlying container, and returns a boost::iterator_range based on a custom iterator that does some processing on the elements.
E.g.
// The range cl...
Interfertile asked 8/9, 2015 at 18:13
2
Solved
The following simplified example compiles in gcc and Visual Studio, but fails in clang !?
namespace N
{
struct A {};
template <typename T>
double operator+ (T a, double d) {return d;}
...
Jijib asked 17/6, 2015 at 17:39
3
I am trying to use boost::lexical_cast on a std::pair<int, int>.
#include <iostream>
#include <utility>
#include <boost/lexical_cast.hpp>
namespace my
{
// When my_pair i...
Tallu asked 4/6, 2015 at 11:2
2
Solved
This question is inspired by this one. Consider the code:
namespace ns {
template <typename T>
void swap(T& a, T& b) {
using namespace std;
swap(a, b);
}
}
After some test wit...
Belmonte asked 4/5, 2015 at 14:12
1
Solved
I am looking into boost::swap implementation:
namespace boost_swap_impl
{
template<class T>
BOOST_GPU_ENABLED
void swap_impl(T& left, T& right)
{
using namespace std;//use std::...
Filthy asked 4/5, 2015 at 13:4
2
Solved
In What is the copy-and-swap idiom this example is shown:
friend void swap(dumb_array& first, dumb_array& second) // nothrow
{
// enable ADL (not necessary in our case, but good practice)...
Stuartstub asked 24/1, 2015 at 21:52
2
Solved
I was having a problem in some production code that I minimized to the following test case:
template<typename T>
void intermediate(T t)
{
func(t); // line 4 ("func not declared in this scop...
Photophore asked 8/4, 2015 at 19:38
2
Solved
Surprisingly the below code compiles and runs without error on a variety of compilers and versions.
#include <iostream>
int main() {
endl(std::cout);
return 0;
}
Ideone link
How does i...
Ingres asked 27/3, 2015 at 7:3
1
Solved
Short question: do operators have special template lookup rules for overload resolution with internal linkage or is the code at the bottom a template overload resolution bug for operators in GCC?
...
Alkoran asked 6/3, 2015 at 17:14
2
I've read that when you're swaping things in c++, you should always using std::swap;, then call swap unqualified, so it automatically picks the std:: ones for std:: and builtin types, your custom o...
Obstructionist asked 25/2, 2015 at 21:17
7
Solved
I have something like this:
#include <iostream>
namespace N
{
typedef std::pair<int, double> MyPair;
std::ostream& operator << (std::ostream& o, MyPair const & mypa...
Denial asked 11/11, 2010 at 14:35
1
Solved
I am trying to understand why the following code does not compile:
namespace ns {
struct S {};
}
namespace alleq {
inline bool
operator==(const ns::S &, const ns::S &)
{
return true;...
Psalmist asked 18/12, 2014 at 10:55
3
Solved
I have the following simplified code
namespace Namespace
{
int foo() { return 1; }
class Class
{
public:
int foo() const { return 2; }
class Nested {
public:
Nested()
{
cout << foo() ...
Bostic asked 10/12, 2014 at 13:30
3
Solved
When I try to compile this code
// void foobar(int);
template <class T>
struct Foo {
void bar(T t) { foobar(t); };
};
void foobar(int);
template class Foo<int>;
with g++ 4.8.2 I...
Puklich asked 27/11, 2014 at 20:48
2
Solved
I'm trying out the code presented by Sean Parent at his talk at GoingNative 2013 - "Inheritance is the base class of evil". (code from the last slide available at https://gist.github.com/berkus/704...
Medulla asked 8/11, 2014 at 20:33
1
Solved
Consider a legacy class template with overloaded addition operators += and +
template<class T>
class X
{
public:
X() = default;
/* implicict */ X(T v): val(v) {}
X<T>& operator...
Sacculus asked 28/9, 2014 at 20:10
3
Solved
Assume the following code:
#include <iostream>
using namespace std;
namespace X
{
class A{};
void f(A a){}
void g(int a){}
}
int main()
{
X::A a;
f(a);
g(5);
}
When I compile th...
Holo asked 22/9, 2014 at 14:14
1
Examples such as enabling outputting of std types explain how ADL can be used to "inject" a certain function/operator, depending on the type the fn/op is applied to.
I was wondering wheter ADL ful...
Horrified asked 5/8, 2014 at 7:31
1
Solved
I think this example best illustrates my question:
namespace N {
class C {
public:
friend bool operator==(const C& c, const C& x) {
return true;
}
friend bool f(const C& c, cons...
Adara asked 11/6, 2014 at 16:37
3
Solved
How can I enable ADL in a constructor initialization list? For example, let's say that I have a bignum that has a namespace-level abs function. Now I want to write a class Foo that initializes its ...
Extrorse asked 25/5, 2014 at 21:11
2
Solved
I have researched and found out that when you want to overload the output stream operator for cout, then the correct way to go about it is to do it this way:
std::ostream& operator<<(std...
Yeager asked 8/3, 2014 at 19:40
2
Solved
I am studying this fascinating answer to a subtle question regarding the best practice to implement the swap function for user-defined types. (My question was initially motivated by a discussion of...
Labium asked 27/1, 2014 at 15:20
© 2022 - 2024 — McMap. All rights reserved.