Skip to content

Instantly share code, notes, and snippets.

@am11
Created October 31, 2015 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save am11/f89618eb3110f18ae320 to your computer and use it in GitHub Desktop.
Save am11/f89618eb3110f18ae320 to your computer and use it in GitHub Desktop.
Overload resolution bug repro in VS2015 RTM (gathered from Stephan T. Lavavej aka STL)
// Discussion: https://github.com/Snaipe/Criterion/issues/51
namespace Std {
template <class Elem> struct CharTraits { };
template <class Elem, class Traits = CharTraits<Elem>> struct BasicOstream {
void operator<<(const void *) = delete;
};
template <class Traits> void operator<<(BasicOstream<char, Traits>&, const char *) = delete;
}
template <typename CharT> struct MyOstream : Std::BasicOstream<char> { };
MyOstream<char> * stream;
#ifdef AVOID_TEMPLATE
MyOstream<char>& call() {
#else
template <typename RandomT = double> MyOstream<char>& call() {
#endif
stream = new MyOstream<char>();
return *stream;
}
int main() {
MyOstream<char>& f = call();
f << "Foo";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment