| Home | Libraries | People | FAQ | More

## 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:

      // public member functions
      variant() = default;
      variant(const variant &) = default;
      variant & operator=(const variant &) = default;
      variant(variant &&) = default;
      variant & operator=(variant &&) = default;
      template<typename T> variant(T &&);
      template<typename T> variant & operator=(T &&);
      template<class... Us> variant(const variant< Us... > &);
      template<class... Us> variant & operator=(const variant< Us... > &);
      index_type size() const;
      unsigned options() const;
      bool inclusive() const;
      bool ordered() const;
      bool continuous() 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<typename Archive> void serialize(Archive &, unsigned);
    };

## Description

### `variant` public member functions

1.     variant() = default;

2.     variant(const variant &) = default;

3.     variant & operator=(const variant &) = default;

4.     variant(variant &&) = default;

5.     variant & operator=(variant &&) = default;

6.     template<typename T> variant(T && t);

7.     template<typename T> variant & operator=(T && t);

8.     template<class... Us> variant(const variant< Us... > & u);

9.     template<class... Us> variant & operator=(const variant< Us... > & u);

10.     index_type size() const;

    Return size of axis.

11.     unsigned options() const;

    Return options of axis or option::none_t if axis has no options.

12.     bool inclusive() const;

    Returns true if the axis is inclusive or false.

13.     bool ordered() const;

    Returns true if the axis is ordered or false.

14.     bool continuous() const;

    Returns true if the axis is continuous or false.

15.     metadata_type & metadata() const;

    Return reference to const metadata or instance of null_type if axis has no metadata.

16.     metadata_type & metadata();

    Return reference to metadata or instance of null_type if axis has no metadata.

17.     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.

18.     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().

19.     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().

20.     template<typename Archive> void serialize(Archive & ar, unsigned);