Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- template<typename Type, typename... Param>
- std::vector<Type> to_vector(Param&&... params)
- {
- std::vector<Type> vect;
- (vect.push_back(params) ...);
- return vect;
- }
- template<typename Iter>
- void print(const Iter& begin, const Iter& end)
- {
- for(auto it = begin; it != end; ++it)
- std::cout << *it << " ";
- std::cout << std::endl;
- }
- int main(int argc, char* argv[])
- {
- auto need_vect = to_vector<double>(1.2, 2.1, 3.0);
- print(need_vect.begin(), need_vect.end());
- return 0;
- }
Add Comment
Please, Sign In to add comment