]> cygwin.com Git - cygwin-apps/setup.git/blame - Generic.h
Also run stratum 'z' perpetual preremove scripts
[cygwin-apps/setup.git] / Generic.h
CommitLineData
31f0ccce
RC
1/*
2 * Copyright (c) 2003 Robert Collins.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <robertc@hotmail.com>
13 *
14 */
15
16#ifndef SETUP_GENERIC_H
17#define SETUP_GENERIC_H
18
19/* Todo fully paramterise */
20template <class _Visitor, class _Predicate>
21struct _visit_if {
22 _visit_if(_Visitor v, _Predicate p) : visitor(v), predicate (p) {}
23 void operator() (typename _Visitor::argument_type& arg) {
24 if (predicate(arg))
25 visitor(arg);
26 }
27 _Visitor visitor;
28 _Predicate predicate;
29};
30
31template <class _Visitor, class _Predicate>
32_visit_if<_Visitor, _Predicate>
33visit_if(_Visitor visitor, _Predicate predicate)
34{
35 return _visit_if<_Visitor, _Predicate>(visitor, predicate);
36}
37
38#endif /* SETUP_GENERIC_H */
This page took 0.100995 seconds and 5 git commands to generate.