Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <algorithm>
- template <class MyType>
- void print(const MyType& container) {
- for (const auto& item : container) {
- std::cout << item << " ";
- }
- std::cout << std::endl;
- }
- template <class T, class G>
- void f(T a, G b) {
- std::cout << a << " " << b << std::endl;
- }
- template<class T>
- T create() {
- return T();
- }
- auto func(int z) {
- if (z == 1) {
- //return 1; error
- }
- return 1.0;
- }
- /*
- template <class T>
- void myfunc(T<int> v) {
- std::cout << v.size() << std::endl;
- }
- */
- int main() {
- //std::vector<int> v;
- //myfunc<std::vector>(v);
- f(1, 3.14);
- f<char>(97, 3.14);
- f<char, int>(98, 3.14);
- std::vector<int> z = {1,2,3,100};
- std::vector<double> d = {1.1,2,3.3,100};
- std::set<char> s = {'q', 'z', 'a', 'r'};
- std::sort(z.begin(), z.end()); // 1, 2, 3, 100
- std::sort(z.rbegin(), z.rend()); // 100, 3, 2, 1
- std::vector<int> qwe = {1,6, 7, 10, 2};
- for (auto it = qwe.begin(); it != qwe.end(); ++it) {
- std::cout << *it << std::endl;
- }
- for (auto it = qwe.rbegin(); it != qwe.rend(); ++it) {
- std::cout << *it << std::endl;
- }
- qwe.insert(qwe.end(), 10); // {1,6, 7, 10, 2};
- /*std::vector<int>* ptr;
- auto& myvector = *ptr;
- myvector[2] = 10;
- (*ptr)[2] = 4;
- ptr->at(2) = 4;
- int* data_ptr = qwe.data();*/
- double zz = func(1);
- std::cout << zz << std::endl;
- print(z);
- print(d);
- print(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement