Something went wrong. Try again.
Java--'s standard template library projects.intra.42.fr/projects/cpp-module-08
Something went wrong. Try again.
586 B · 30 lines
C++
at main
12345678910111213141516171819202122232425262728293031#pragma once
#include <stdexcept>#include <vector>
class Span { public: Span(); Span(const Span& other); Span(unsigned int size);
void addNumber(int number); template <typename I> void addNumbers(I begin, I end) { if (numbers.size() + static_cast<std::size_t>(std::distance(begin, end)) > size) throw std::length_error("Can't add numbers, it would exceed span size");
numbers.insert(numbers.end(), begin, end); }
int shortestSpan(); int longestSpan();
Span& operator=(const Span& other);
~Span();
private: std::vector<int> numbers; unsigned int size;};