Lumiera  0.pre.03
»edit your freedom«
builder-qualifier-support.hpp
Go to the documentation of this file.
1 /*
2  BUILDER-QUALIFIER-SUPPORT.hpp - accept arbitrary qualifier terms for builder functions
3 
4  Copyright (C) Lumiera.org
5  2022, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
50 #ifndef LIB_BUILDER_QUALIFIER_SUPPORT_H
51 #define LIB_BUILDER_QUALIFIER_SUPPORT_H
52 
53 
54 #include <functional>
55 
56 
57 namespace lib {
58 
71  template<class TAR>
73  {
74  protected:
75  using Manipulator = std::function<void(TAR&)>;
76 
77  struct Qualifier
78  : Manipulator
79  {
80  using Manipulator::Manipulator;
81  };
82 
84  template<class... QUALS>
85  friend void qualify(TAR& target, Qualifier& qualifier, QUALS& ...qs)
86  {
87  qualifier(target);
88  qualify(target, qs...);
89  }
90 
91  friend void qualify(TAR&){ }
92 
93  public:
94  // default construct and copyable
95  };
96 
97 
98 }// namespace lib
99 #endif /*LIB_BUILDER_QUALIFIER_SUPPORT_H*/
Mix-in to accept and apply an arbitrary sequence of qualifier functors.
Implementation namespace for support and library code.
friend void qualify(TAR &target, Qualifier &qualifier, QUALS &...qs)
Main entrance point: apply the given qualifiers in sequence to the target.