1/*=============================================================================
2 Copyright (c) 2022 Denis Mikhailov
3 Distributed under the Boost Software License, Version 1.0. (See accompanying
4 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5==============================================================================*/
6
7#if !defined(BOOST_FUSION_TRANSFORM_VIEW_DEREF_DATA_IMPL_JAN_9_2022_0354PM)
8#define BOOST_FUSION_TRANSFORM_VIEW_DEREF_DATA_IMPL_JAN_9_2022_0354PM
9
10#include <boost/fusion/support/config.hpp>
11#include <boost/fusion/iterator/deref.hpp>
12#include <boost/type_traits/remove_reference.hpp>
13#include <boost/type_traits/remove_const.hpp>
14#include <boost/type_traits/add_reference.hpp>
15#include <boost/type_traits/add_const.hpp>
16#include <boost/type_traits/is_reference.hpp>
17#include <boost/type_traits/is_const.hpp>
18#include <boost/utility/result_of.hpp>
19#include <boost/mpl/if.hpp>
20
21namespace boost { namespace fusion
22{
23 struct transform_view_iterator_tag;
24 struct transform_view_iterator2_tag;
25
26 namespace extension
27 {
28 template<typename Tag>
29 struct deref_data_impl;
30
31 // Unary Version
32 template<>
33 struct deref_data_impl<transform_view_iterator_tag>
34 {
35 template <typename Iterator>
36 struct apply
37 {
38 typedef typename
39 result_of::deref<typename Iterator::first_type>::type
40 value_type;
41
42 typedef typename Iterator::transform_type F;
43 typedef typename boost::result_of<F(value_type)>::type transformed_type;
44 typedef typename boost::remove_reference<transformed_type>::type transformed_type_unref;
45 typedef typename boost::remove_const<transformed_type_unref>::type transformed_type_unconst;
46
47 typedef typename transformed_type_unconst::second_type raw_type;
48 typedef typename
49 boost::mpl::if_<
50 is_reference<transformed_type>
51 , typename boost::mpl::if_<
52 is_const<transformed_type_unref>
53 , typename boost::add_reference<typename boost::add_const<raw_type>::type>::type
54 , typename boost::add_reference<raw_type>::type
55 >::type
56 , raw_type
57 >::type
58 type;
59
60 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
61 static type
62 call(Iterator const& i)
63 {
64 return i.f(fusion::deref(i.first)).second;
65 }
66 };
67 };
68
69 // Binary Version is not supported with Associative Sequence
70 }
71}}
72
73#endif
74