June 14th, 2015


What do I do when there's no STL algorithm I need

  1. template <class NeedleIterator, class HaystackIterator>

  2. bool equals_zip(

  3.  NeedleIterator needle_begin, NeedleIterator needle_end,

  4.  HaystackIterator haystack_begin, HaystackIterator haystack_end

  5. ) {

  6.  while (needle_begin != needle_end) {

  7.    if (haystack_begin == haystack_end)

  8.      return false;

  9.    if (!(*needle_begin == *haystack_begin))

  10.      return false;

  11.    ++needle_begin;

  12.    ++haystack_begin;

  13.  }

  14.  return true;

  15. }


Screw Scala

Development in C++ seemed OK while I knew nothing about path-dependent types. I've just been writing a parser that would be 10x more simple with PD-types and realized there's no way even to emulate some.

UPD. I've just got terrorized by the fact that I don't even need path-dependent types. There are places where C++ is not type safe through all the sorts of compile-time magic I've put into that program. Java-style child classes would be enough. I don't even see a way child classes are incompatible to "zero overhead" rule. Gosh, there's something in Java that is not disgusting after all.

For all the interested among the readers, here's a description of the use case. Write a PEG-parser combinator language in C++ that is optimized by having primitives implemented via CRTP. Avoid passing end iterator of the parsed range through all the combinators.