I am trying to use std :: initializer_list as an argument in a function that uses argument-dependent search (ADL). But I do not work, and I do not understand why. The following is a minimal example:
#include <initializer_list>
#include <iostream>
class Foo {
public:
inline friend void bar(std::initializer_list<Foo> v) {
std::cout << "size = " << v.size() << std::endl;
}
};
void baz(std::initializer_list<Foo> v) {
std::cout << "size = " << v.size() << std::endl;
}
int main(){
Foo a;
baz({a,a});
return 0;
}
As you can see above, the equivalent global function works fine. Why does the above not work?
I am using clang for OS X 10.10.
source
share