Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template variant

boost::histogram::axis::variant — Polymorphic axis type.

Synopsis

// In header: <boost/histogram/axis/variant.hpp>

template<class... Ts> 
class variant :
  public boost::histogram::axis::iterator_mixin< variant< Ts... > >
{
public:
  // construct/copy/destruct
  variant() = default;
  variant(const variant &) = default;
  variant(variant &&) = default;
  template<typename T, typename  = requires_bounded_type<T> > variant(T &&);
  template<class... Us> variant(const variant< Us... > &);
  variant & operator=(const variant &) = default;
  variant & operator=(variant &&) = default;
  template<typename T, typename  = requires_bounded_type<T> > 
    variant & operator=(T &&);
  template<class... Us> variant & operator=(const variant< Us... > &);

  // public member functions
  index_type size() const;
  unsigned options() const;
  const metadata_type & metadata() const;
  metadata_type & metadata();
  template<typename U> index_type index(const U &) const;
  double value(real_index_type) const;
  auto bin(index_type) const;
  template<class... Us> bool operator==(const variant< Us... > &) const;
  template<typename T> bool operator==(const T &) const;
  template<typename T> bool operator!=(const T &) const;
  template<typename Archive> void serialize(Archive &, unsigned);

  // friend functions
  template<typename Visitor, typename Variant> 
    friend auto visit(Visitor &&, Variant &&);
  template<typename T, class... Us> friend T & get(variant< Us... > &);
  template<typename T, class... Us> 
    friend const T & get(const variant< Us... > &);
  template<typename T, class... Us> friend T && get(variant< Us... > &&);
  template<typename T, class... Us> friend T * get_if(variant< Us... > *);
  template<typename T, class... Us> 
    friend const T * get_if(const variant< Us... > *);
};

Description

variant public construct/copy/destruct

  1. variant() = default;
  2. variant(const variant &) = default;
  3. variant(variant &&) = default;
  4. template<typename T, typename  = requires_bounded_type<T> > variant(T && t);
  5. template<class... Us> variant(const variant< Us... > & u);
  6. variant & operator=(const variant &) = default;
  7. variant & operator=(variant &&) = default;
  8. template<typename T, typename  = requires_bounded_type<T> > 
      variant & operator=(T && t);
  9. template<class... Us> variant & operator=(const variant< Us... > & u);

variant public member functions

  1. index_type size() const;
    Return size of axis.
  2. unsigned options() const;
    Return options of axis or option::none_t if axis has no options.
  3. const metadata_type & metadata() const;
    Return reference to const metadata or instance of null_type if axis has no metadata.
  4. metadata_type & metadata();
    Return reference to metadata or instance of null_type if axis has no metadata.
  5. template<typename U> index_type index(const U & u) const;
    Return index for value argument.

    Throws std::invalid_argument if axis has incompatible call signature.

  6. double value(real_index_type idx) const;
    Return value for index argument.

    Only works for axes with value method that returns something convertible to double and will throw a runtime_error otherwise, see axis::traits::value().

  7. auto bin(index_type idx) const;
    Return bin for index argument.

    Only works for axes with value method that returns something convertible to double and will throw a runtime_error otherwise, see axis::traits::value().

  8. template<class... Us> bool operator==(const variant< Us... > & u) const;
  9. template<typename T> bool operator==(const T & t) const;
  10. template<typename T> bool operator!=(const T & t) const;
  11. template<typename Archive> void serialize(Archive & ar, unsigned);

variant friend functions

  1. template<typename Visitor, typename Variant> 
      friend auto visit(Visitor &&, Variant &&);
    Apply visitor to variant.
  2. template<typename T, class... Us> friend T & get(variant< Us... > & v);
    Return lvalue reference to T, throws unspecified exception if type does not match.
  3. template<typename T, class... Us> 
      friend const T & get(const variant< Us... > & v);
    Return const reference to T, throws unspecified exception if type does not match.
  4. template<typename T, class... Us> friend T && get(variant< Us... > && v);
    Return rvalue reference to T, throws unspecified exception if type does not match.
  5. template<typename T, class... Us> friend T * get_if(variant< Us... > * v);
    Returns pointer to T in variant or null pointer if type does not match.
  6. template<typename T, class... Us> 
      friend const T * get_if(const variant< Us... > * v);
    Returns pointer to const T in variant or null pointer if type does not match.

PrevUpHomeNext