Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <template <typename> class TCont, typename TType>
- TCont<TType> fill_from(int count, std::istream& from)
- {
- TCont<TType> seq;
- seq.reserve(count);
- std::copy(
- std::istream_iterator<TType>(from),
- std::istream_iterator<TType>(),
- std::inserter(seq, seq.end()));
- return seq;
- }
- int main()
- {
- int n;
- std::cin >> n;
- std::vector<int> list_form = fill_from<std::vector, int>(n, std::cin);
- }
- /*
- * Input:
- * 4
- * 1 2 3 4
- *
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement