81 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			81 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								#ifndef ALSK_ALSK_EDSL_OP_IMPL_WHILE_H
							 | 
						||
| 
								 | 
							
								#define ALSK_ALSK_EDSL_OP_IMPL_WHILE_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include <utility>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "../traits.h"
							 | 
						||
| 
								 | 
							
								#include "../../../skeleton/bone/while.h"
							 | 
						||
| 
								 | 
							
								#include "../../../skeleton/struct/struct.h"
							 | 
						||
| 
								 | 
							
								#include "../../../skeleton/link/link.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace alsk {
							 | 
						||
| 
								 | 
							
								namespace edsl {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								template<typename Signature_, typename Cond, typename Task>
							 | 
						||
| 
								 | 
							
								struct While: OperandBase {
							 | 
						||
| 
								 | 
							
									Cond cond;
							 | 
						||
| 
								 | 
							
									Task task;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									constexpr While(Cond cond, Task task)
							 | 
						||
| 
								 | 
							
									noexcept(noexcept(Cond{std::move(cond)}) and noexcept(Task{std::move(task)})):
							 | 
						||
| 
								 | 
							
										cond{std::move(cond)}, task{std::move(task)}
							 | 
						||
| 
								 | 
							
									{}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									template<typename S>
							 | 
						||
| 
								 | 
							
									constexpr While(While<S, Cond, Task> const& o)
							 | 
						||
| 
								 | 
							
									noexcept(noexcept(Cond{o.cond}) and noexcept(Task{o.task})):
							 | 
						||
| 
								 | 
							
										cond{o.cond}, task{o.task}
							 | 
						||
| 
								 | 
							
									{}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									template<typename S>
							 | 
						||
| 
								 | 
							
									constexpr While(While<S, Cond, Task>&& o)
							 | 
						||
| 
								 | 
							
									noexcept(noexcept(Cond{std::move(o.cond)}) and noexcept(Task{std::move(o.task)})):
							 | 
						||
| 
								 | 
							
										cond{std::move(o.cond)}, task{std::move(o.task)}
							 | 
						||
| 
								 | 
							
									{}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									using Signature = Signature_;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									using Struct    = S<alsk::While, typename Cond::Struct, typename Task::Struct>;
							 | 
						||
| 
								 | 
							
									using Links     = L<alsk::While, Signature, typename Cond::Links, typename Task::Links>;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									template<typename S>
							 | 
						||
| 
								 | 
							
									constexpr void setup(S& skeleton) const {
							 | 
						||
| 
								 | 
							
										setupFor(cond, skeleton.cond);
							 | 
						||
| 
								 | 
							
										setupFor(task, skeleton.task);
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									template<typename Signature>
							 | 
						||
| 
								 | 
							
									constexpr auto link() const&& {
							 | 
						||
| 
								 | 
							
										return While<Signature, Cond, Task>{std::move(*this)};
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									template<typename Signature>
							 | 
						||
| 
								 | 
							
									constexpr auto link() const& {
							 | 
						||
| 
								 | 
							
										return While<Signature, Cond, Task>{*this};
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace impl {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								template<typename Cond, typename Signature>
							 | 
						||
| 
								 | 
							
								struct WhilePart {
							 | 
						||
| 
								 | 
							
									Cond const& cond;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									template<typename Task, std::enable_if_t<isOperand<Task>>* = nullptr>
							 | 
						||
| 
								 | 
							
									constexpr auto do_(Task const& task) {
							 | 
						||
| 
								 | 
							
										return alsk::edsl::While<Signature, Cond, Task>{cond, task};
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								template<typename Signature = void(), typename Cond, std::enable_if_t<isOperand<Cond>>* = nullptr>
							 | 
						||
| 
								 | 
							
								constexpr auto while_(Cond const& cond) {
							 | 
						||
| 
								 | 
							
									return impl::WhilePart<Cond, Signature>{cond};
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif
							 |