[PATCH] Implement std::experimental::sample
Eric Fiselier
eric at efcs.ca
Fri Apr 24 09:33:18 PDT 2015
In http://reviews.llvm.org/D9044#156827, @eugenis wrote:
> In http://reviews.llvm.org/D9044#156813, @EricWF wrote:
>
> > You'll need to use reserved identifiers
>
>
> Do you mean for local variable names? Is there a technical reason for this, or just a code style thing?
For any name not defined in the standard you should use reserved identifiers. Assume that the user of the standard library defines every non-reserved, non-defined name as a macro. We use reserved identifiers so that conforming programs can define non-reserved names globally and still use the standard library.
For example:
#define PopulationIterator char*
#define SampleIterator char*
#define UniformRandomNumberGenerator &rand
#include <experimental/algorithm>
> > and guard the definition of `sample` inside a C++14 only block because adding a new definition of could break existing code.
>
>
> n4335 does not seem to require that this is only available in C++14. And aren't names under std:: already reserved, and an addition of a new std:: name could not break compliant code?
I would prefer not to restrict these things to c++14 only, although there may be a reason that conforming implementations need to that isn't visible in n4335.
However because `sample` is a function it can be looked up by ADL. Since `sample` takes user-defined iterator types and RNG's it is possible that existing unqualified calls to `sample` in user code may now find `std::sample`.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9044
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list