diff options
Diffstat (limited to 'boost/histogram/axis/variable.hpp')
-rw-r--r-- | boost/histogram/axis/variable.hpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/boost/histogram/axis/variable.hpp b/boost/histogram/axis/variable.hpp index d3d6b855cf..10641c96ee 100644 --- a/boost/histogram/axis/variable.hpp +++ b/boost/histogram/axis/variable.hpp @@ -13,13 +13,18 @@ #include <boost/histogram/axis/iterator.hpp> #include <boost/histogram/axis/option.hpp> #include <boost/histogram/detail/compressed_pair.hpp> -#include <boost/histogram/detail/meta.hpp> +#include <boost/histogram/detail/convert_integer.hpp> +#include <boost/histogram/detail/detect.hpp> +#include <boost/histogram/detail/limits.hpp> +#include <boost/histogram/detail/relaxed_equal.hpp> +#include <boost/histogram/detail/replace_default.hpp> #include <boost/histogram/fwd.hpp> #include <boost/throw_exception.hpp> #include <cmath> #include <limits> #include <memory> #include <stdexcept> +#include <string> #include <type_traits> #include <utility> #include <vector> @@ -52,7 +57,23 @@ class variable : public iterator_mixin<variable<Value, MetaData, Options, Alloca using vec_type = std::vector<Value, allocator_type>; public: - explicit variable(allocator_type alloc = {}) : vec_meta_(std::move(alloc)) {} + explicit variable(allocator_type alloc = {}) : vec_meta_(vec_type{alloc}) {} + variable(const variable&) = default; + variable& operator=(const variable&) = default; + variable(variable&& o) noexcept : vec_meta_(std::move(o.vec_meta_)) { + // std::string explicitly guarantees nothrow only in C++17 + static_assert(std::is_same<metadata_type, std::string>::value || + std::is_nothrow_move_constructible<metadata_type>::value, + ""); + } + variable& operator=(variable&& o) noexcept { + // std::string explicitly guarantees nothrow only in C++17 + static_assert(std::is_same<metadata_type, std::string>::value || + std::is_nothrow_move_assignable<metadata_type>::value, + ""); + vec_meta_ = std::move(o.vec_meta_); + return *this; + } /** Construct from iterator range of bin edges. * @@ -215,22 +236,19 @@ variable(std::initializer_list<U>, const char*)->variable<T>; template <class U, class M, class T = detail::convert_integer<U, double>> variable(std::initializer_list<U>, M)->variable<T, M>; -template < - class Iterable, - class T = detail::convert_integer< - detail::remove_cvref_t<decltype(*std::begin(std::declval<Iterable&>()))>, double>> +template <class Iterable, + class T = detail::convert_integer< + std::decay_t<decltype(*std::begin(std::declval<Iterable&>()))>, double>> variable(Iterable)->variable<T>; -template < - class Iterable, - class T = detail::convert_integer< - detail::remove_cvref_t<decltype(*std::begin(std::declval<Iterable&>()))>, double>> +template <class Iterable, + class T = detail::convert_integer< + std::decay_t<decltype(*std::begin(std::declval<Iterable&>()))>, double>> variable(Iterable, const char*)->variable<T>; -template < - class Iterable, class M, - class T = detail::convert_integer< - detail::remove_cvref_t<decltype(*std::begin(std::declval<Iterable&>()))>, double>> +template <class Iterable, class M, + class T = detail::convert_integer< + std::decay_t<decltype(*std::begin(std::declval<Iterable&>()))>, double>> variable(Iterable, M)->variable<T, M>; #endif |