Commit graph

35 commits

Author SHA1 Message Date
4988153e15 Library: prevent implicit bool conversion on iterator-like objects
...it should have been this way all the time.
Generic code might otherwise be ill guided to assume a conversion
from the Iterator to its value type, while in fact an explicit dereferentiation is necessary
2018-09-14 21:06:14 +02:00
1df77cc4ff Library: investigate and fix an insidious problem with move-forwarding (util::join / transformIter)
As it turned out, we had two bugs luring in the code base,
with the happy result of one cancelling out the adverse effects of the other

:-D

 - a mistake in the invocation of the Itertools (transform, filter,...)
   caused them to move and consume any input passed by forwarding, instead
   of consuming only the RValue references.
 - but util::join did an extraneous copy on its data source, meaning that
   in all relevant cases where a *copy* got passed into the Itertools,
   only that spurious temporary was consumed by Bug #1.

(Note that most usages of Itertools rely on RValues anyway, since the whole
point of Itertools is to write concise in-line transformation pipelines...)

*** Added additional testcode to prove util::stringify() behaves correct
    now in all cases.
2017-12-04 04:23:30 +01:00
0682e449a3 Library: a pseudo-iterator to yield just a single value
...which can be helpful when a function usually returns a somewhat dressed-up iterator,
but needs to return a specific fixed value under some circumstances
2017-10-29 14:51:51 +01:00
7e241d9a11 Library: a little bit of modernising and overhaul
- fix some warnings due to uninitialised members
  (no real problem, since these members get assigned anyway)
- use a lambda as example function right in the test
- use move initialisation and the new util::join
2017-10-29 13:22:25 +01:00
d4ac2d78e2 C++11: improve moving and forwarding of iterators
this becomes more relevant now, since the actual MutationMessage iterators
are implemented in terms of a shared_ptr to IterSource. Thus, when building
processing pipelines, we most definitively want to move that smart-ptr into
the destination, since this avoids touching the shared count and thus avoids
generating unnecessary memory barriers.
2017-08-12 03:01:35 +02:00
afe07bdb16 decommission the safe-bool-idiom (closes #477)
obsoleted by C++11

 * in most cases, it can be replaced by an explicit conversion operator
 * especially for the Lumiera Forward Iterators, we need an implicit conversion
2017-04-02 06:42:23 +02:00
58898997d8 Function-Tools: get rid of the old-style FunctionSignature template
...it is now completely redundant, even superseded by the new _Fun
signature trait (which additionally also handles lambdas)
2017-03-19 04:09:24 +01:00
1a4b6545a0 maximum munch
...feels like X-mas
2016-12-23 04:23:03 +01:00
c9d113be87 EventLog: implement match backwards
..based on the new IterCursor, which gives us the ability
to switch the iteration direction
2015-12-06 03:35:07 +01:00
00abf9f1f9 err: got the naming and the junctor condition backwards
the junctor is called "before" but searches ahead.
And in this case we do not need to *extend* the filter condition,
just replace it with a new one...
2015-12-05 03:37:25 +01:00
9300a0baaf code up the first event log matching predicate
this establishes the basic pattern used for implementation
Note: test still fails
2015-12-05 02:40:03 +01:00
6659a7dee1 augment extensible filter to add the obvious variations
that is
 - allow also for a disjunctive extension
 - allow for negated conditions
 - allow to flip the current condition

unit test PASS
2015-12-05 02:00:44 +01:00
0e41555402 extensible filter: add re-evaluation (test PASS)
this is the tiny bit of operational functionality needed on top:
whenever we're reconfiguring the predicate, we need to re-trigger
the evaluation (and clear the cached value)

n.b.: I've verified in debugger that the closure is
allocated on the heap and the functors are passed by value
2015-12-05 01:31:23 +01:00
075653a815 define the expected behaviour for an extensible filter iterator 2015-12-05 00:52:45 +01:00
68dd8a9e03 refine implementation draft: make FilterIter extensible on-the-fly
after looking into our various iterator tools,
it seems obvious that our filtering iterator implementation
has almost all of the required behaviour; we only need to
add a hook to rewrite and extend the filtering functor,
which can now nicely done with a lambda closure.

This means all memory management, if necessary, is
pushed into std::function and the automated memory
management for closures provided by the runtime.
2015-12-05 00:28:07 +01:00
08e7e3df15 prefer more readable bool operator spelling
especially the '!' for negation is sometimes too terse
and easily overlooked.
2015-09-25 03:12:04 +02:00
657f0031f4 Generic Record: reorganise type configuration
this solves the problem how to deal with value access
- for the simple default (string) implementation,
  we use a 'key = val' syntax and thus have to split strings,
  which means we need to return contents by value
- for the actual relevant use case we have GenNode entries,
  which may recursively hold further Records. For dealing
  with diff messages over this data struture, its a good
  idea to allow for const& value access (otherwise we'd
  end up copying large subtrees for trivial operaions)
2015-08-17 02:40:57 +02:00
ce7c38312d iterator improvements: use Lumiera Forward Iterator in range for loops
This is kind of the logic consequence, since we consider our
functional iterator concept still superior and will continue
to rely on it.

For some time now, I've considered to build a generic bridge
function, to use enable_if and metaprogramming to figure out
if some type is a "Lumiera Forward Iterator" automatically.
But since our concept is to some degree a contract regarding
semantics, which never can be captured by any kind of introspection,
such a bridge implementation would be rather heuristic and
bears the danger to trigger on types actually not intended
as iterator at all. So I consider such a solution as dangerous
and we'll settle with just supplying the necessary bridge
functions as free functions injected for ADL on a case by case base
2015-08-16 01:35:28 +02:00
7be1b7d35d Switch from TR1 preveiw to the new standard headers
- functional
- memory
- unordered collections
2014-04-03 22:42:48 +02:00
697924925c pragmatic fix for the long-standing problem of detecting increment operator
our duck-detector had a shortcoming here and failed
to detect iterators, in case the increment operator
was inherited from a mix-in
2012-10-10 05:20:17 +02:00
0ab773ab7c helper to pull all elements from an iterator, yielding the last one 2012-10-10 05:20:13 +02:00
00c08bd27b fix helper functions not declared as inline 2012-01-07 03:11:02 +01:00
d9f84a9bfd clean up lib/meta namespaces 2011-12-03 03:15:59 +01:00
3f1b7651e9 GPL header whitespace 2010-12-17 23:28:49 +01:00
ff2113e61f implement an duplicate-value filtering iterator 2010-01-06 06:19:30 +01:00
0081b36793 Itertools: add caching to FilterIter
filter predicate is now evaluated at most once
2010-01-06 06:16:30 +01:00
7d913dc558 start moving some metaprogramming helpers to lib::meta 2010-01-04 10:08:14 +01:00
e838d46336 Fix: operator++ needs to return the actual target type
see Ticket #486
2010-01-03 05:42:35 +01:00
7b7e9096a3 Hook up scope contents iterator in PlacementIndex (closes #343) 2009-12-27 06:25:34 +01:00
26c506c0d6 rewrite TransformIter, allowing to return references (closes #475) 2009-12-27 04:03:00 +01:00
4773305853 Fix itertools: allow TransformIter to return an reference 2009-12-19 03:55:02 +01:00
451253ae8a utility to append elements from an Lumiera Forward Iterator until exhaustion 2009-11-22 01:14:27 +01:00
d0c905b5c9 add an transforming iterator to the itertools 2009-11-13 03:26:20 +01:00
a86517bd4f extend the protocol of the itertools core, abstracting the increment 2009-11-13 01:02:31 +01:00
1c72cbb599 Iterator tools: (1) a filtering iterator 2009-11-02 06:06:43 +01:00