Or you could have the function's (or function template's) parameters be an iterator pair instead, then overload with convenience functions for various containers as desired.Originally Posted by Elysia
Or you could have the function's (or function template's) parameters be an iterator pair instead, then overload with convenience functions for various containers as desired.Originally Posted by Elysia
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
This concept is utterly destroyed because of the idiotic requirement. Yes, it is an idiotic requirement; protecting clients from themselves isn't a sufficient reason to even try to enforce it. Trying to do this, as you are pretending to want, requires that every component of the system that uses an array in almost any capacity be a template. At that point the complain that templates bloat code will be true, but no one, including you remember (earlier thread), will agree to follow such a broken requirement.But this may be a good thing.
If a developer can't or refuses to use the alternatives--to arrays--starting with such a template is simply wrong.
Soma
Oh, come on. Who says it must be the only function?
You can have more overloads for other types such as containers and iterators, all which just call a generic function in a safe way.
Limited, well-defined interfaces allow for less bugs at runtime AFAIK, which is a good thing™. I'm not suggesting you should go overboard with it, as it is pointless if it never used and code duplication is evil™. There is a tradeoff, but I'm just throwing some few nudgets here.
No one said that. But I am not going to create tons of overloads for differently sized arrays. Templates ease the pains of doing that, but then we come back to the problems noted in the previous replies. Templates might as well be a requirement for functions that use arrays like this in any capacity.Oh, come on. Who says it must be the only function?
You can have more overloads for other types such as containers and iterators, all which just call a generic function in a safe way.
Those overloads for other types necessarily involve separating a normal array target from its size and allowing it to decay into a pointer.You can have more overloads for other types such as containers and iterators, all which just call a generic function in a safe way.
You and what you are forwarding are trying to avoid exactly that.
Soma
I mean, C arrays should just be used as a last resort. std::array or std::vector is far better, and 99% of the time, you will be using them, and we agree that when using them, there are no problems, right?
You can catch the rest of the C arrays with few a few overloads.
I'm losing track of what exactly people are arguing about here :/
>> I mean, C arrays should just be used as a last resort.
Whatever you say, I mean this is a new one in a never ending list of comebacks you have.
>> You can catch the rest of the C arrays with few a few overloads.
>> I'm losing track of what exactly people are arguing about here :/
What argument
Last edited by whiteflags; 09-01-2012 at 07:05 AM.