4 ms·
> What triggers the optimization should be the value type of the range, not the type of the value to be filled in. As the article says, you have to do at least
by quietbritishjim 7y ago
> What triggers the optimization should be the value type of the range, not the type of the value to be filled in.
As the article says, you have to do at least some checking on the type of the source value, because it could be a user-defined type with an overloaded implicit conversion operator (operator char()) that does something non-trivial. (I'm not completely sure that my comment contradicts what you've just said, but that's because I don't quite see what you're saying.)
- gpderetta 7y agoSure, but the enable_if<is_scalar<> > already takes care of it, I'm not suggesting taking the check away (although it might be possible to relax it to checking whether a type is trivially constructible and copyable). Now that I think of it you probably need to check that both the iterator value type and the value itself are trivially copyable, constructible and that the value is trivially convertible to the iterator value type itself. No wonder that the std library maintainers went for the easier way.