Alias template parameter to a private function

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 29 13:21:13 PDT 2017


On 06/24/2017 02:04 AM, Sebastien Alaiwan wrote:

 > private:
 >
 > void privateFunction1()
 > {
 >   auto array = [0, 1, 2, 3, 4, 5];
 >   auto result = filter!isValid(array); // error: 'isValid' is private
 > }

 > bool isValid(int i)
 > {
 >   return i % 2 == 0;
 > }

A workaround is to use a lambda:

   filter!(a => isValid(a))(array)

Such limitations are pretty annoying. There were a number of similar 
issues in recent dmd releases. Please file a bug if it's not already there:

   https://issues.dlang.org/

Ali



More information about the Digitalmars-d-learn mailing list