Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Reference

Precise Reflection
Flat Reflection
Include all

Precise Reflection

Includes all the Boost.PFR headers that do not define flat_* functions, except boost/pfr/precise/global_ops.hpp

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> 
      decltype(auto) constexpr get(const T &);
    template<std::size_t I, typename T> decltype(auto) constexpr get(T &);
    template<typename T> constexpr auto structure_to_tuple(const T &);
    template<typename T> constexpr auto structure_tie(T &);
    template<typename T, typename F> void for_each_field(T &&, F &&);
    template<typename... Elements> 
      unspecified tie_from_structure(Elements &...);
  }
}
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;
  }
}

Contains comparison operators and stream operators for any types that do not have their own operators. If type is comparable or streamable using it's own operator (but not it's conversion operator), then the original operator is used.

Example:

#include <boost/pfr/precise/global_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(s1 < s2);
std::cout << s1 << std::endl; // 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.

This header defines:

template<typename T, typename U> 
  unspecified operator==(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator!=(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator<(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator>(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator<=(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator>=(const T & lhs, const U & rhs);
template<typename Char, typename Traits, typename T> 
  std::enable_if_t< std::is_pod< T >::value, std::basic_ostream< Char, Traits > & > 
  operator<<(std::basic_ostream< Char, Traits > & out, const T & value);
template<typename Char, typename Traits, typename T> 
  std::enable_if_t< std::is_pod< T >::value, std::basic_istream< Char, Traits > & > 
  operator>>(std::basic_istream< Char, Traits > & in, T & value);
template<typename T> std::size_t hash_value(const T & value);
namespace boost {
  namespace pfr {
    template<typename Char, typename Traits, typename T> 
      void write(std::basic_ostream< Char, Traits > &, const T &);
    template<typename Char, typename Traits, typename T> 
      void read(std::basic_istream< Char, Traits > &, T &);
  }
}

Contains comparison operators and stream operators for types that do not have their own operators. If type is comparable or streamable using it's own operator or it's conversion operator, then the original operator is used.

Just write using namespace ops; and operators will be available in scope.

Requires: C++17 or C++14 constexpr aggregate intializable type.

Example:

#include <boost/pfr/precise/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;
};
// ...

using namespace ops;

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(s1 < s2);
std::cout << s1 << std::endl; // 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.

This header contains:

namespace boost {
  namespace pfr {
    namespace ops {
      template<typename T> 
        unspecified operator==(const T & lhs, const T & rhs);
      template<typename T> 
        unspecified operator!=(const T & lhs, const T & rhs);
      template<typename T> unspecified operator<(const T & lhs, const T & rhs);
      template<typename T> unspecified operator>(const T & lhs, const T & rhs);
      template<typename T> 
        unspecified operator<=(const T & lhs, const T & rhs);
      template<typename T> 
        unspecified operator>=(const T & lhs, const T & rhs);
      template<typename Char, typename Traits, typename T> 
        unspecified operator<<(std::basic_ostream< Char, Traits > & out, 
                               const T & value);
      template<typename Char, typename Traits, typename T> 
        unspecified operator>>(std::basic_istream< Char, Traits > & in, 
                               T & value);
      template<typename T> 
        std::enable_if_t< std::is_pod< T >::value, std::size_t > 
        hash_value(const T & value);
    }
  }
}
namespace boost {
  namespace pfr {
    typedef unspecified tuple_size;

    constexpr std::size_t tuple_size_v;
  }
}

Flat Reflection

Includes all the Boost.PFR headers that define flat_* functions, except boost/pfr/flat/global_ops.hpp

namespace boost {
  namespace pfr {
    typedef unspecified flat_tuple_element;
    typedef typename flat_tuple_element< I, T >::type flat_tuple_element_t;
    template<std::size_t I, typename T> decltype(auto) flat_get(const T &);
    template<std::size_t I, typename T> decltype(auto) flat_get(T &);
    template<typename T> auto flat_structure_to_tuple(const T &);
    template<typename T> auto flat_structure_tie(T &);
    template<typename T, typename F> void flat_for_each_field(T &&, F &&);
    template<typename... Elements> 
      unspecified flat_tie_from_structure(Elements &...);
  }
}
namespace boost {
  namespace pfr {
    template<typename T = void> struct flat_equal_to;
    template<typename T = void> struct flat_greater;
    template<typename T = void> struct flat_greater_equal;
    template<typename T> struct flat_hash;
    template<typename T = void> struct flat_less;
    template<typename T = void> struct flat_less_equal;
    template<typename T = void> struct flat_not_equal;
  }
}

Contains comparison operators and stream operators for any POD types that do not have their own operators. If POD is comparable or streamable using it's own operator (but not it's conversion operator), then the original operator is used.

Example:

#include <boost/pfr/flat/global_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(s1 < s2);
std::cout << s1 << std::endl; // Outputs: {0, 1, H, e, l, l, o, , , 0, 6, 7, 8, 9, 10, 11}

Note: If reflecting structures with enums may reinterpret_cast enum to a reference to underlying type.

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

This header defines:

template<typename T, typename U> 
  unspecified operator==(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator!=(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator<(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator>(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator<=(const T & lhs, const U & rhs);
template<typename T, typename U> 
  unspecified operator>=(const T & lhs, const U & rhs);
template<typename Char, typename Traits, typename T> 
  std::enable_if_t< std::is_pod< T >::value, std::basic_ostream< Char, Traits > & > 
  operator<<(std::basic_ostream< Char, Traits > & out, const T & value);
template<typename Char, typename Traits, typename T> 
  std::enable_if_t< std::is_pod< T >::value, std::basic_istream< Char, Traits > & > 
  operator>>(std::basic_istream< Char, Traits > & in, T & value);
template<typename T> 
  std::enable_if_t< std::is_pod< T >::value, std::size_t > 
  hash_value(const T & value);
namespace boost {
  namespace pfr {
    template<typename Char, typename Traits, typename T> 
      void flat_write(std::basic_ostream< Char, Traits > &, const T &);
    template<typename Char, typename Traits, typename T> 
      void flat_read(std::basic_istream< Char, Traits > &, T &);
  }
}

Contains comparison operators and stream operators for any POD types that do not have their own operators. If POD is comparable or streamable using it's own operator or it's conversion operator, then the original operator is used.

Just write using namespace flat_ops; and operators will be available in scope.

Example:

#include <boost/pfr/flat/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;
};
// ...

using namespace flat_ops;

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(s1 < s2);
std::cout << s1 << std::endl; // Outputs: {0, 1, H, e, l, l, o, , , 0, 6, 7, 8, 9, 10, 11}

Note: If reflecting structures with enums may reinterpret_cast enum to a reference to underlying type.

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

This header contains:

namespace boost {
  namespace pfr {
    namespace flat_ops {
      template<typename T> 
        unspecified operator==(const T & lhs, const T & rhs);
      template<typename T> 
        unspecified operator!=(const T & lhs, const T & rhs);
      template<typename T> unspecified operator<(const T & lhs, const T & rhs);
      template<typename T> unspecified operator>(const T & lhs, const T & rhs);
      template<typename T> 
        unspecified operator<=(const T & lhs, const T & rhs);
      template<typename T> 
        unspecified operator>=(const T & lhs, const T & rhs);
      template<typename Char, typename Traits, typename T> 
        unspecified operator<<(std::basic_ostream< Char, Traits > & out, 
                               const T & value);
      template<typename Char, typename Traits, typename T> 
        unspecified operator>>(std::basic_istream< Char, Traits > & in, 
                               T & value);
      template<typename T> 
        std::enable_if_t< std::is_pod< T >::value, std::size_t > 
        hash_value(const T & value);
    }
  }
}
namespace boost {
  namespace pfr {
    typedef unspecified flat_tuple_size;

    constexpr std::size_t flat_tuple_size_v;
  }
}

Include all

Header <boost/pfr.hpp>

Includes all the Boost.PFR headers, except boost/pfr/flat/global_ops.hpp and boost/pfr/precise/global_ops.hpp


PrevUpHomeNext