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)
5  2022, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
41 #ifndef LIB_BUILDER_QUALIFIER_SUPPORT_H
42 #define LIB_BUILDER_QUALIFIER_SUPPORT_H
43 
44 
45 #include <functional>
46 
47 
48 namespace lib {
49 
62  template<class TAR>
64  {
65  protected:
66  using Manipulator = std::function<void(TAR&)>;
67 
68  struct Qualifier
69  : Manipulator
70  {
71  using Manipulator::Manipulator;
72  };
73 
75  template<class... QUALS>
76  friend void qualify(TAR& target, Qualifier& qualifier, QUALS& ...qs)
77  {
78  qualifier(target);
79  qualify(target, qs...);
80  }
81 
82  friend void qualify(TAR&){ }
83 
84  public:
85  // default construct and copyable
86  };
87 
88 
89 }// namespace lib
90 #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.