#include <string>
struct Bob
{
template<class T>
void operator () () const
{
T t;
}
template<class T>
operator T () const
{
T t;
return t;
}
};
int main()
{
Bob b;
std::string s = static_cast<std::string>(b);
}
I2luY2x1ZGUgPHN0cmluZz4Kc3RydWN0IEJvYgoJewoJCXRlbXBsYXRlPGNsYXNzIFQ+CgkJdm9pZCBvcGVyYXRvciAoKSAoKSBjb25zdAoJCXsKCQkJVCB0OwoJCX0KCgkJdGVtcGxhdGU8Y2xhc3MgVD4KCQlvcGVyYXRvciBUICgpIGNvbnN0CgkJewoJCQlUIHQ7CgkJCXJldHVybiB0OwoJCX0KCX07CgkKICAgIGludCBtYWluKCkKICAgIHsKCUJvYiBiOwoJc3RkOjpzdHJpbmcgcyA9IHN0YXRpY19jYXN0PHN0ZDo6c3RyaW5nPihiKTsKICAgIH0=
prog.cpp: In function ‘int main()’:
prog.cpp:21:44: error: call of overloaded ‘basic_string(Bob&)’ is ambiguous
std::string s = static_cast<std::string>(b);
^
prog.cpp:21:44: note: candidates are:
In file included from /usr/include/c++/4.8/string:52:0,
from prog.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:522:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc());
^
/usr/include/c++/4.8/bits/basic_string.h:507:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
basic_string(basic_string&& __str) noexcept
^
/usr/include/c++/4.8/bits/basic_string.h:490:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
^
/usr/include/c++/4.8/bits/basic_string.h:455:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
basic_string(const basic_string& __str);
^
/usr/include/c++/4.8/bits/basic_string.h:448:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
basic_string(const _Alloc& __a);
^