26 #ifndef TILEDARRAY_TILE_INTERFACE_CAST_H__INCLUDED
27 #define TILEDARRAY_TILE_INTERFACE_CAST_H__INCLUDED
30 #include "../type_traits.h"
34 template <
typename Result,
typename Arg,
typename Enabler =
void>
37 namespace tile_interface {
39 template <
typename Result,
typename Arg,
typename Enabler>
52 template <
typename Result,
typename Arg>
54 std::enable_if_t<detail::has_conversion_operator_v<
55 Arg, madness::Future<Result>> ||
56 detail::is_convertible_v<Arg, Result>>> {
60 static const constexpr
bool is_nonblocking =
65 static_assert(std::is_same<
result_type, std::decay_t<result_type>>::value,
66 "Cast<Result,Arg>: Result must be a non-const non-ref type");
67 static_assert(std::is_same<
argument_type, std::decay_t<argument_type>>::value,
68 "Cast<Result,Arg>: Arg must be a non-const non-ref type");
71 detail::is_convertible_v<argument_type, result_type>,
72 "Cast<Result,Arg> does not know how to construct Result or "
73 "Future<Result> from Arg");
76 template <
typename Result_,
typename Arg_,
77 typename = std::enable_if_t<
79 static auto invoker(Arg_&& arg) {
80 auto exec = [](Arg_&& arg) {
81 return static_cast<Result_
>(std::forward<Arg_>(arg));
85 template <
typename Result_,
typename Arg_>
89 !madness::is_future<Result_>::value &&
93 auto exec = [](Arg_&& arg) {
103 template <
typename Arg_,
104 typename = std::enable_if_t<std::is_same<
105 argument_type, madness::remove_fcvr_t<Arg_>>::value>>
107 return this->invoker<result_type>(arg);
122 template <
typename Result,
typename Arg>
124 typename std::enable_if<
125 is_lazy_tile<Arg>::value &&
126 !std::is_same<Result, typename TiledArray::eval_trait<
127 Arg>::type>::value>::type> {
149 template <
typename Arg_,
typename = std::enable_if_t<std::is_same<
167 template <
typename Result,
typename Arg,
typename Enabler>
175 madness::remove_fcvr_t<Arg>>::type>
183 #endif // TILEDARRAY_TILE_INTERFACE_CAST_H__INCLUDED