/* This file is part of KDBindings. SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> Author: Sean Harmer <sean.harmer@kdab.com> SPDX-License-Identifier: MIT Contact KDAB at <info@kdab.com> for commercial licensing options.*/#pragma once#include<kdbindings/node.h>#include<type_traits>namespaceKDBindings{namespacePrivate{template<typenameT>structbindable_value_type_{usingtype=T;};template<typenameT>structbindable_value_type_<Property<T>>{usingtype=T;};template<typenameT>structbindable_value_type_<NodeInterface<T>>{usingtype=T;};template<typenameT>structbindable_value_type_<Node<T>>{usingtype=T;};template<typenameT>structbindable_value_type:bindable_value_type_<std::decay_t<T>>{};template<typenameT>usingbindable_value_type_t=typenamebindable_value_type<T>::type;// Find the type of a Node wrapping an operator and argumentstemplate<typenameOperator,typename...Ts>usingoperator_node_result=std::decay<std::invoke_result_t<std::decay_t<Operator>,bindable_value_type_t<Ts>...>>;template<typenameOperator,typename...Ts>usingoperator_node_result_t=typenameoperator_node_result<Operator,Ts...>::type;// Node creation helperstemplate<typenameT>inlineNode<std::decay_t<T>>makeNode(T&&value){returnNode<std::decay_t<T>>(std::make_unique<ConstantNode<std::decay_t<T>>>(std::move(value)));}template<typenameT>inlineNode<T>makeNode(Property<T>&property){returnNode<T>(std::make_unique<PropertyNode<T>>(property));}template<typenameT>inlineNode<T>makeNode(Node<T>&&node){returnstd::move(node);}template<typenameOperator,typename...Ts,typename=std::enable_if_t<sizeof...(Ts)>=1>,typenameResultType=operator_node_result_t<Operator,Ts...>>inlineNode<ResultType>makeNode(Operator&&op,Ts&&...args){returnNode<ResultType>(std::make_unique<OperatorNode<ResultType,std::decay_t<Operator>,bindable_value_type_t<Ts>...>>(std::forward<Operator>(op),makeNode(std::forward<Ts>(args))...));}// Needed by function and operator helperstemplate<typenameT>structis_bindable:std::integral_constant<bool,is_property<T>::value||is_node<T>::value>{};}// namespace Private}// namespace KDBindings