3 ms·
No, that's not what I'm saying. I have no idea where you saw me saying anything about those 2 lines or vectors in my sentences. I am saying 1-arg constructors
by dataflow 2y ago
No, that's not what I'm saying. I have no idea where you saw me saying anything about those 2 lines or vectors in my sentences.
I am saying 1-arg constructors that aren't semantically "conversions" from that arg need to be be explicit, not implicit. If you make them implicit, that's your mistake; tools can catch that mistake statically.
- g15jv2dp 2y agoUh. I'll try to be more explicit. Let's say that someone in a library somewhere has made what you consider to be a mistake. Or they consider something to be a conversion but the constructor is not trivial. For the push_back construction, can you then say what the call does without knowing the types?
- dataflow 2y ago> Let's say that someone in a library somewhere has made what you consider to be a mistake. Or they consider something to be a conversion but the constructor is not trivial. For the push_back construction, can you then say what the call does without knowing the types? I don't get the point of your question. You might as well ask: "Let's say someone in a library somewhere has defined their type's operator< to wipe your disk. If you see std::less<>()(a, b), can you say what the call does without knowing the types?" To which the answer is... well, obviously, no. Same answer to your question. What is this supposed to imply?
- lumb63 2y agoThis conversation makes me really happy I have successfully avoided C++ for the past two years.
- dataflow 2y agoThere was very little in this conversation that was C++ specific, so it's kind of baffling that this conversation led you to that conclusion. But in general: yes, that's a good thing. Don't use C++ if you don't need to. It has too many sharp edges and it shouldn't be used unless it's really necessary.
- Kamq 2y agoLet's narrow this down even more. Someone has made an implicit constructor that makes a network call because... people are dumb. This implicit constructor takes an integer. Does the following code make a network call? vec.push_back(4);
- dataflow 2y agoThat obviously depends on the type of vec, which you've given no information about.