updated wrong noexcepts and throw statements
This commit is contained in:
parent
67d3a2f4cf
commit
f08c2890f1
|
|
@ -48,7 +48,7 @@ namespace cc {
|
|||
template <std::size_t N2>
|
||||
constexpr explicit const_vector(const value_type (&array)[N2]) noexcept;
|
||||
|
||||
constexpr const_vector(std::initializer_list<value_type> values) noexcept;
|
||||
constexpr const_vector(std::initializer_list<value_type> values);
|
||||
|
||||
template<std::input_iterator InputIt>
|
||||
constexpr const_vector(InputIt first, InputIt last);
|
||||
|
|
@ -62,7 +62,7 @@ namespace cc {
|
|||
|
||||
constexpr ~const_vector() = default; // elements in static array should be destroyed automatically
|
||||
|
||||
constexpr const_vector<T, N>& operator=(const const_vector& other); // needed to handle *this = *this
|
||||
constexpr const_vector<T, N>& operator=(const const_vector& other) noexcept; // needed to handle *this = *this
|
||||
template <std::size_t N2>
|
||||
constexpr const_vector<T, N>& operator=(const const_vector<value_type, N2>& other);
|
||||
constexpr const_vector<T, N>& operator=(const_vector&& other) noexcept;
|
||||
|
|
@ -70,8 +70,8 @@ namespace cc {
|
|||
constexpr const_vector<T, N>& operator=(const_vector<value_type, N2>&& other);
|
||||
//constexpr const_vector<T, N>& operator=(const value_type (&array)[N]) noexcept; // not needed as functionally equivalent to templated overload
|
||||
template <std::size_t N2>
|
||||
constexpr const_vector<T, N>& operator=(const value_type (&array)[N2]) noexcept;
|
||||
constexpr const_vector<T, N>& operator=(std::initializer_list<value_type> values) noexcept;
|
||||
constexpr const_vector<T, N>& operator=(const value_type (&array)[N2]);
|
||||
constexpr const_vector<T, N>& operator=(std::initializer_list<value_type> values);
|
||||
|
||||
constexpr void assign(size_type count, const value_type& value) noexcept;
|
||||
template<std::input_iterator InputIt>
|
||||
|
|
@ -217,9 +217,10 @@ namespace cc {
|
|||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
constexpr const_vector<T, N>::const_vector(std::initializer_list<value_type> values) noexcept
|
||||
constexpr const_vector<T, N>::const_vector(std::initializer_list<value_type> values)
|
||||
: _size(values.size())
|
||||
{
|
||||
if (values.size() > N) throw std::invalid_argument("Initializer list in assign has more elements than size" + std::to_string(values.size()) + ">=" + std::to_string(N));
|
||||
std::move(values.begin(), values.end(), _arr);
|
||||
}
|
||||
|
||||
|
|
@ -266,10 +267,13 @@ namespace cc {
|
|||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
constexpr const_vector<T, N> &const_vector<T, N>::operator=(const const_vector &other)
|
||||
constexpr const_vector<T, N> &const_vector<T, N>::operator=(const const_vector &other) noexcept
|
||||
{
|
||||
if (this == &other) return *this;
|
||||
|
||||
// event though assign may throw an exception noexcept for this operator should be fine,
|
||||
// as std::distance(other.begin(), other.end()) cannot be greater than the capacity,
|
||||
// because the signatures would have to differ
|
||||
assign(other.begin(), other.end());
|
||||
|
||||
return *this;
|
||||
|
|
@ -282,7 +286,7 @@ namespace cc {
|
|||
if (other.size() > _len) throw std::invalid_argument("size of other has to be equal to or smaller than this");
|
||||
|
||||
// this is not necessary, as it should call the non templated operator=
|
||||
// (and it throws an error without a cast)
|
||||
// (and throws an error without a cast)
|
||||
//if (this == &other) return *this;
|
||||
|
||||
assign(other.begin(), other.end());
|
||||
|
|
@ -319,14 +323,14 @@ namespace cc {
|
|||
|
||||
template<typename T, std::size_t N>
|
||||
template<std::size_t N2>
|
||||
constexpr const_vector<T, N> &const_vector<T, N>::operator=(const value_type (&array)[N2]) noexcept
|
||||
constexpr const_vector<T, N> &const_vector<T, N>::operator=(const value_type (&array)[N2])
|
||||
{
|
||||
assign(std::begin(array), std::end(array));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
constexpr const_vector<T, N> &const_vector<T, N>::operator=(std::initializer_list<value_type> values) noexcept
|
||||
constexpr const_vector<T, N> &const_vector<T, N>::operator=(std::initializer_list<value_type> values)
|
||||
{
|
||||
assign(std::move(values));
|
||||
return *this;
|
||||
|
|
|
|||
Loading…
Reference in New Issue