| Home | Libraries | People | FAQ | More

## Reference Section of PFR

### Header <boost/pfr.hpp>

Includes all the Boost.PFR headers

### Header <boost/pfr/config.hpp>

Contains all the macros that describe Boost.PFR configuration, like BOOST_PFR_ENABLED

| Note
This header file doesn't require C++14 Standard and supports all C++ compilers, even pre C++14 compilers (C++11, C++03...).

    BOOST_PFR_NOT_SUPPORTED
    BOOST_PFR_USE_LOOPHOLE
    BOOST_PFR_USE_CPP17
    BOOST_PFR_USE_STD_MAKE_INTEGRAL_SEQUENCE
    BOOST_PFR_HAS_GUARANTEED_COPY_ELISION
    BOOST_PFR_ENABLE_IMPLICIT_REFLECTION
    BOOST_PFR_CORE_NAME_ENABLED
    BOOST_PFR_CORE_NAME_PARSING
    BOOST_PFR_MAYBE_UNUSED
    BOOST_PFR_ENABLED
    BOOST_PFR_BEGIN_MODULE_EXPORT
    BOOST_PFR_END_MODULE_EXPORT

### Header <boost/pfr/core.hpp>

Contains all the basic tuple-like interfaces boost::pfr::get , boost::pfr::tuple_size , boost::pfr::tuple_element_t , and others.

Synopsis:

    namespace boost {
      namespace pfr {
        typedef unspecified tuple_element;
        typedef typename tuple_element< I, T >::type tuple_element_t;
        template<std::size_t I, typename T>
          BOOST_PFR_BEGIN_MODULE_EXPORT constexpr decltype(auto) get(const T &);
        template<std::size_t I, typename T>
          decltype(auto)
          get(T & val,
              std::enable_if_t< std::is_assignable< T, T >::value > * = nullptr);
        template<std::size_t I, typename T>
          auto get(T &,
                   std::enable_if_t<!std::is_assignable< T, T >::value > * = nullptr);
        template<std::size_t I, typename T>
          auto get(T && val,
                   std::enable_if_t< std::is_rvalue_reference< T && >::value > * = nullptr);
        template<typename U, typename T> const U & get(const T & val);
        template<typename U, typename T>
          U & get(T & val,
                  std::enable_if_t< std::is_assignable< T, T >::value > * = nullptr);
        template<typename U, typename T>
          U & get(T &,
                  std::enable_if_t<!std::is_assignable< T, T >::value > * = nullptr);
        template<typename U, typename T>
          U && get(T && val,
                   std::enable_if_t< std::is_rvalue_reference< T && >::value > * = nullptr);
        template<typename T> auto structure_to_tuple(const T &);
        template<typename... Elements>
          unspecified tie_from_structure(Elements &... args);
      }
    }

### Header <boost/pfr/core_name.hpp>

Contains functions boost::pfr::get_name and boost::pfr::names_as_array to know which names each field of any simple aggregate has.

See Also : 'Reflection of field names' for details.

Synopsis:

    namespace boost {
      namespace pfr {
        template<std::size_t I, typename T>
          BOOST_PFR_BEGIN_MODULE_EXPORT constexpr std::string_view get_name();
        template<typename T>
          std::array< std::string_view, boost::pfr::tuple_size_v< T > >
          names_as_array();
        template<typename T, typename F> void for_each_field_with_name(T &&, F &&);
      }
    }

### Header <boost/pfr/functions_for.hpp>

Contains BOOST_PFR_FUNCTIONS_FOR macro that defined comparison and stream operators for T along with hash_value function. Example:

    #include <boost/pfr/functions_for.hpp>

    namespace my_namespace {
        struct my_struct {      // No operators defined for that structure
            int i; short s; char data[7]; bool bl; int a,b,c,d,e,f;
        };
        BOOST_PFR_FUNCTIONS_FOR(my_struct)
    }

See Also : 'Three ways of getting operators' for other ways to define operators and more details.

Synopsis:

    BOOST_PFR_FUNCTIONS_FOR(T)

### Header <boost/pfr/functors.hpp>

Contains functors that are close to the Standard Library ones. Each functor calls corresponding Boost.PFR function from boost/pfr/ops.hpp

Example:

    #include <boost/pfr/functors.hpp>
    struct my_struct {      // No operators defined for that structure
        int i; short s; char data[7]; bool bl; int a,b,c,d,e,f;
    };
    // ...

    std::unordered_set<
        my_struct,
        boost::pfr::hash<>,
        boost::pfr::equal_to<>
    > my_set;

Synopsis:

    namespace boost {
      namespace pfr {
        template<typename T = void> struct equal_to;
        template<typename T = void> struct greater;
        template<typename T = void> struct greater_equal;
        template<typename T> struct hash;
        template<typename T = void> struct less;
        template<typename T = void> struct less_equal;
        template<typename T = void> struct not_equal;
      }
    }

### Header <boost/pfr/io.hpp>

Contains IO stream manipulator boost::pfr::io for types. If type is streamable using its own operator or its conversion operator, then the types operator is used.

Example:

    #include <boost/pfr/io.hpp>
    struct comparable_struct {      // No operators defined for that structure
        int i; short s; char data[7]; bool bl; int a,b,c,d,e,f;
    };
    // ...

    comparable_struct s1 {0, 1, "Hello", false, 6,7,8,9,10,11};
    std::cout << boost::pfr::io(s1);  // Outputs: {0, 1, H, e, l, l, o, , , 0, 6, 7, 8, 9, 10, 11}

See Also : 'Three ways of getting operators' for other ways to define operators and more details.

Synopsis:

    namespace boost {
      namespace pfr {
        template<typename T> BOOST_PFR_BEGIN_MODULE_EXPORT auto io(T &&);
      }
    }

### Header <boost/pfr/io_fields.hpp>

Contains IO manipulator boost::pfr::io_fields to read/write any simple aggregate field-by-field.

Example:

    struct my_struct {
        int i;
        short s;
    };

    std::ostream& operator<<(std::ostream& os, const my_struct& x) {
        return os << boost::pfr::io_fields(x);  // Equivalent to: os << "{ " << x.i << " ," <<  x.s << " }"
    }

    std::istream& operator>>(std::istream& is, my_struct& x) {
        return is >> boost::pfr::io_fields(x);  // Equivalent to: is >> "{ " >> x.i >> " ," >>  x.s >> " }"
    }

See Also : 'Three ways of getting operators' for other ways to define operators and more details.

Synopsis:

    namespace boost {
      namespace pfr {
        template<typename T> BOOST_PFR_BEGIN_MODULE_EXPORT auto io_fields(T &&);
      }
    }

### Header <boost/pfr/ops.hpp>

Contains comparison and hashing functions. If type is comparable using its own operator or its conversion operator, then the types operator is used. Otherwise the operation is done via corresponding function from boost/pfr/ops.hpp header.

Example:

    #include <boost/pfr/ops.hpp>
    struct comparable_struct {      // No operators defined for that structure
        int i; short s; char data[7]; bool bl; int a,b,c,d,e,f;
    };
    // ...

    comparable_struct s1 {0, 1, "Hello", false, 6,7,8,9,10,11};
    comparable_struct s2 {0, 1, "Hello", false, 6,7,8,9,10,11111};
    assert(boost::pfr::lt(s1, s2));

See Also : 'Three ways of getting operators' for other ways to define operators and more details.

Synopsis:

    namespace boost {
      namespace pfr {
        template<typename T, typename U> unspecified eq(const T &, const U &);
        template<typename T, typename U>
          unspecified eq(const T & lhs, const U & rhs);
        template<typename T, typename U> unspecified ne(const T &, const U &);
        template<typename T, typename U>
          unspecified ne(const T & lhs, const U & rhs);
        template<typename T, typename U> unspecified lt(const T &, const U &);
        template<typename T, typename U>
          unspecified lt(const T & lhs, const U & rhs);
        template<typename T, typename U> unspecified gt(const T &, const U &);
        template<typename T, typename U>
          unspecified gt(const T & lhs, const U & rhs);
        template<typename T, typename U> unspecified le(const T &, const U &);
        template<typename T, typename U>
          unspecified le(const T & lhs, const U & rhs);
        template<typename T, typename U> unspecified ge(const T &, const U &);
        template<typename T, typename U>
          unspecified ge(const T & lhs, const U & rhs);
        template<typename T> unspecified hash_value(const T &);
        template<typename T> unspecified hash_value(const T & value);
      }
    }

### Header <boost/pfr/ops_fields.hpp>

Contains field-by-fields comparison and hash functions.

Example:

    #include <boost/pfr/ops_fields.hpp>
    struct comparable_struct {      // No operators defined for that structure
        int i; short s;
    };
    // ...

    comparable_struct s1 {0, 1};
    comparable_struct s2 {0, 2};
    assert(boost::pfr::lt_fields(s1, s2));

See Also : 'Three ways of getting operators' for other ways to define operators and more details.

Synopsis:

    namespace boost {
      namespace pfr {
        template<typename T, typename U>
          BOOST_PFR_BEGIN_MODULE_EXPORT constexpr bool
          eq_fields(const T &, const U &);
        template<typename T, typename U> bool ne_fields(const T &, const U &);
        template<typename T, typename U> bool gt_fields(const T &, const U &);
        template<typename T, typename U> bool lt_fields(const T &, const U &);
        template<typename T, typename U> bool ge_fields(const T &, const U &);
        template<typename T, typename U> bool le_fields(const T &, const U &);
        template<typename T> std::size_t hash_fields(const T &);
      }
    }

### Header <boost/pfr/traits.hpp>

Contains traits boost::pfr::is_reflectable and boost::pfr::is_implicitly_reflectable for detecting an ability to reflect type.

Synopsis:

    namespace boost {
      namespace pfr {
        template<typename T, typename WhatFor>
          struct is_reflectable<const T, WhatFor>;
        template<typename T, typename WhatFor>
          struct is_reflectable<const volatile T, WhatFor>;
        template<typename T, typename WhatFor>
          struct is_reflectable<volatile T, WhatFor>;
        typedef unspecified is_implicitly_reflectable;

        bool is_implicitly_reflectable_v;
      }
    }

### Header <boost/pfr/traits_fwd.hpp>

    namespace boost {
      namespace pfr {
        template<typename T, typename WhatFor> struct is_reflectable;
      }
    }

### Header <boost/pfr/tuple_size.hpp>

Contains tuple-like interfaces to get fields count boost::pfr::tuple_size , boost::pfr::tuple_size_v .

Synopsis:

    namespace boost {
      namespace pfr {
        typedef unspecified tuple_size;

        std::size_t tuple_size_v;
      }
    }