File indexing completed on 2024-06-16 05:06:54
0001 /* 0002 SPDX-FileCopyrightText: 2018 Ivan Čukić <ivan.cukic(at)kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef VOY_OPERATIONS_IDENTITY_H 0008 #define VOY_OPERATIONS_IDENTITY_H 0009 0010 // STL 0011 #include <functional> 0012 0013 // Self 0014 #include "../utils.h" 0015 #include "../traits.h" 0016 #include "../dsl/node_tags.h" 0017 0018 namespace voy { 0019 0020 using voy::utils::non_copyable; 0021 0022 using voy::dsl::continuator_base, 0023 voy::dsl::transformation_node_tag; 0024 0025 template <typename = void> 0026 class identity { 0027 public: 0028 using node_category = transformation_node_tag; 0029 0030 explicit identity() 0031 { 0032 } 0033 0034 template <typename Cont> 0035 class node: public continuator_base<Cont>, non_copyable { 0036 using base = continuator_base<Cont>; 0037 0038 public: 0039 node(Cont&& continuation) 0040 : base{std::move(continuation)} 0041 { 0042 } 0043 0044 template <typename T> 0045 void operator() (T&& value) const 0046 { 0047 base::emit(voy_fwd(value)); 0048 } 0049 }; 0050 0051 template <typename Cont> 0052 auto with_continuation(Cont&& cont) && 0053 { 0054 return node<Cont>(voy_fwd(cont)); 0055 } 0056 }; 0057 0058 } // namespace voy 0059 0060 #endif // include guard 0061