News for hackers. Stuff that matters.
Re:My Delorean runs Perl by nrdvana on Monday January 29, 2018 @08:08PM (#16262102)
What I'm talking about is arbitrary attributes that might not exist on the base class, resulting in something like:

  std::sort(
    myvec.begin(), 
    myvec.end(), 
    [](obj& A, obj& b) {
      int A_attr1= dynamic_cast<Thing1*>(&A)? dynamic_cast<Thing1*>(&A)->attr1
                 : dynamic_cast<Thing2*>(&A)? dynamic_cast<Thing2*>(&A)->attr1
                 : -1;
      int B_attr1= dynamic_cast<Thing1*>(&B)? dynamic_cast<Thing1*>(&B)->attr1
                 : dynamic_cast<Thing2*>(&B)? dynamic_cast<Thing2*>(&B)->attr1
                 : -1;
      return A_attr1 < B_attr1;
    }
  );
and then compare that to

  @list= sort { ($a->{attr1} // -1) <=> ($b->{attr1} // -1) } @list;

There are no comments on this comment yet.