Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • That is an interesting "feature" in g++ indeed. I suppose that is either a bug which only checks one type deep instead of going recursively down as far as possible at compile time to generate the correct code, or there is a flag that needs to be set in your g++ command. Commented Mar 15, 2013 at 17:37
  • 3
    en.cppreference.com/w/cpp/language/implicit_cast it seems that g++ is following the standard quite strictly. It is Microsoft or Mac's compiler that is being a bit too generous with the O.P.'s code. Especially telling is the statement: "When considering the argument to a constructor or to a user-defined conversion function, only one standard conversion sequence is allowed (otherwise user-defined conversions could be effectively chained). " Commented Mar 15, 2013 at 17:42
  • Yeah, I just threw the code together to test out some of the gcc compiler options (which it doesn't look like there are any to address this particular case). I didn't look much further into it (I'm supposed to be working :-) but given gcc's adherence to the standard and the use of the explicit keyword a compiler option was probably deemed unnecessary. Commented Mar 15, 2013 at 17:58
  • 1
    Implicit conversions are not chained, and a Texture should probably not be constructed implicitly (according to guidelines in other answers), so a better call-site would be renderer.Draw(Texture("foo.png")); (assuming it works as I expect). Commented Nov 16, 2015 at 22:39