Skip to content

Commit

Permalink
[pfr_extension] Implemented macro adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
denzor200 committed Jan 23, 2022
1 parent c243f8b commit 74dcf5c
Show file tree
Hide file tree
Showing 20 changed files with 923 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ target_link_libraries(boost_fusion
Boost::type_traits
Boost::typeof
Boost::utility
Boost::pfr
)
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ install:
- git submodule init libs/type_traits
- git submodule init libs/typeof
- git submodule init libs/utility
- git submodule init libs/pfr

- git submodule init libs/headers tools/boost_install tools/build
- git submodule update
Expand Down
8 changes: 8 additions & 0 deletions include/boost/fusion/adapted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@
#include <boost/fusion/adapted/std_tuple.hpp>
#endif

// Unfortunately, there is no way to determine the compatibility of the pfr library with the current compiler.
// The "boost/fusion/adapted/pfr.hpp" include has been commented out to ensure backward compatibility
// Please include it manually in your project

// #if !defined(BOOST_FUSION_NO_PFR)
// #include <boost/fusion/adapted/pfr.hpp>
// #endif

#endif
21 changes: 21 additions & 0 deletions include/boost/fusion/adapted/pfr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#ifndef BOOST_FUSION_ADAPTED_PFR_HPP
#define BOOST_FUSION_ADAPTED_PFR_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/pfr/detail/at_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/begin_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/end_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/size_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/value_at_impl.hpp>
#include <boost/fusion/adapted/pfr/adapt_pfr.hpp>

#endif
99 changes: 99 additions & 0 deletions include/boost/fusion/adapted/pfr/adapt_pfr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_STRUCT_ADAPT_PFR_HPP)
#define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_PFR_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/fusion/adapted/pfr/detail/at_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/begin_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/category_of_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/end_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/is_sequence_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/is_view_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/size_impl.hpp>
#include <boost/fusion/adapted/pfr/detail/value_at_impl.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>

#define BOOST_FUSION_ADAPT_PFR(NAME) \
\
namespace boost { namespace fusion { \
struct pfr_tag; \
struct fusion_sequence_tag; \
\
namespace traits \
{ \
template<> \
struct tag_of<NAME> \
{ \
using type = pfr_tag; \
}; \
template<> \
struct tag_of<NAME const> \
{ \
using type = pfr_tag; \
}; \
} \
}} \
\
namespace boost { namespace mpl \
{ \
template<typename> \
struct sequence_tag; \
\
template<> \
struct sequence_tag<NAME> \
{ \
using type = fusion::fusion_sequence_tag; \
}; \
\
template<> \
struct sequence_tag<NAME const> \
{ \
using type = fusion::fusion_sequence_tag; \
}; \
}}

#define BOOST_FUSION_ADAPT_TPL_PFR(NAME) \
\
namespace boost { namespace fusion { \
struct pfr_tag; \
struct fusion_sequence_tag; \
\
namespace traits \
{ \
template<typename... Args> \
struct tag_of<NAME<Args...>> \
{ \
using type = pfr_tag; \
}; \
template<typename... Args> \
struct tag_of<NAME<Args...> const> \
{ \
using type = pfr_tag; \
}; \
} \
}} \
\
namespace boost { namespace mpl \
{ \
template<typename> \
struct sequence_tag; \
\
template<typename... Args> \
struct sequence_tag<NAME<Args...>> \
{ \
using type = fusion::fusion_sequence_tag; \
}; \
\
template<typename... Args> \
struct sequence_tag<NAME<Args...> const> \
{ \
using type = fusion::fusion_sequence_tag; \
}; \
}}

#endif
43 changes: 43 additions & 0 deletions include/boost/fusion/adapted/pfr/detail/at_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_PFR_DETAIL_AT_IMPL_HPP)
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_AT_IMPL_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/fusion/view/pfr_fields_view.hpp>
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>

namespace boost { namespace fusion
{
struct pfr_tag;

namespace extension
{
template<typename T>
struct at_impl;

template<>
struct at_impl<pfr_tag>
{
template <typename Aggregate, typename N>
struct apply
{
using type = typename result_of::at< pfr_fields_view<Aggregate>, N >::type;

constexpr BOOST_FUSION_GPU_ENABLED
static type
call(Aggregate& seq)
{
return at<N>(pfr_fields(seq));
}
};
};
}
}}

#endif
43 changes: 43 additions & 0 deletions include/boost/fusion/adapted/pfr/detail/begin_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_PFR_DETAIL_BEGIN_IMPL_HPP)
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_BEGIN_IMPL_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/fusion/view/pfr_fields_view.hpp>
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
#include <boost/fusion/sequence/intrinsic/begin.hpp>

namespace boost { namespace fusion
{
struct pfr_tag;

namespace extension
{
template<typename T>
struct begin_impl;

template <>
struct begin_impl<pfr_tag>
{
template <typename Aggregate>
struct apply
{
using type = typename result_of::begin< pfr_fields_view<Aggregate> >::type;

constexpr BOOST_FUSION_GPU_ENABLED
static type
call(Aggregate& seq)
{
return begin(pfr_fields(seq));
}
};
};
}
}}

#endif
34 changes: 34 additions & 0 deletions include/boost/fusion/adapted/pfr/detail/category_of_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_PFR_DETAIL_CATEGORY_OF_IMPL_HPP)
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_CATEGORY_OF_IMPL_HPP

#include <boost/fusion/support/config.hpp>

namespace boost { namespace fusion
{
struct pfr_tag;
struct random_access_traversal_tag;

namespace extension
{
template<typename T>
struct category_of_impl;

template<>
struct category_of_impl<pfr_tag>
{
template<typename T>
struct apply
{
using type = random_access_traversal_tag;
};
};
}
}}

#endif
43 changes: 43 additions & 0 deletions include/boost/fusion/adapted/pfr/detail/end_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_PFR_DETAIL_END_IMPL_HPP)
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_END_IMPL_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/fusion/view/pfr_fields_view.hpp>
#include <boost/fusion/algorithm/auxiliary/pfr_fields.hpp>
#include <boost/fusion/sequence/intrinsic/end.hpp>

namespace boost { namespace fusion
{
struct pfr_tag;

namespace extension
{
template<typename T>
struct end_impl;

template<>
struct end_impl<pfr_tag>
{
template <typename Aggregate>
struct apply
{
using type = typename result_of::end< pfr_fields_view<Aggregate> >::type;

constexpr BOOST_FUSION_GPU_ENABLED
static type
call(Aggregate& seq)
{
return end(pfr_fields(seq));
}
};
};
}
}}

#endif
31 changes: 31 additions & 0 deletions include/boost/fusion/adapted/pfr/detail/is_sequence_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_PFR_DETAIL_IS_SEQUENCE_IMPL_HPP)
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_IS_SEQUENCE_IMPL_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>

namespace boost { namespace fusion
{
struct pfr_tag;

namespace extension
{
template<typename Tag>
struct is_sequence_impl;

template<>
struct is_sequence_impl<pfr_tag>
{
template<typename Aggregate>
struct apply : mpl::true_ {};
};
}
}}

#endif
31 changes: 31 additions & 0 deletions include/boost/fusion/adapted/pfr/detail/is_view_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*=============================================================================
Copyright (c) 2022 Denis Mikhailov
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#if !defined(BOOST_FUSION_ADAPTED_PFR_DETAIL_IS_VIEW_IMPL_HPP)
#define BOOST_FUSION_ADAPTED_PFR_DETAIL_IS_VIEW_IMPL_HPP

#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>

namespace boost { namespace fusion
{
struct pfr_tag;

namespace extension
{
template<typename Tag>
struct is_view_impl;

template<>
struct is_view_impl<pfr_tag>
{
template<typename T>
struct apply : mpl::false_ {};
};
}
}}

#endif

0 comments on commit 74dcf5c

Please sign in to comment.