This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename... Args> | |
| void print(Args&&... args) { | |
| using dummy = int[]; | |
| (void)dummy{0, (void(cout << std::forward<Args>(args)), 0)...}; | |
| cout << endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename T, size_t n> | |
| void copy_array(T (&src)[n], T (&dst)[n]) | |
| { | |
| for (size_t i = 0; i < n; i++) | |
| { | |
| dst[i] = src[i]; | |
| } | |
| } | |
| int main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var i = 0; | |
| function loop () { | |
| setTimeout(function () { | |
| doSomething(); | |
| i++; | |
| if (i < 20) { | |
| loop(); | |
| } | |
| }, 300) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename F,typename A> | |
| std::future<std::result_of<F(A&&)>::type> | |
| spawn(F&& f,A&& a) | |
| { | |
| typedef std::result_of<F(A&&)>::type result_type; | |
| std::packaged_task<result_type(A&&)> | |
| task(std::move(f))); | |
| std::future<result_type> res(task.get_future()); | |
| std::thread t(std::move(task),std::move(a)); | |
| t.detach(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| Consider next number sequence | |
| F(1) = 1 | |
| F(2) = 2 | |
| F(3) = 3 | |
| F(n) = 1*F(n-1) + 2*F(n-2) + 3*F(n-3) | |
| Here we are interested only in parity of numbers. | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <chrono> | |
| #include <iostream> | |
| #include <random> | |
| #include <vector> | |
| using std::cout; | |
| using std::endl; | |
| using std::vector; | |
| class TestRandom { |
NewerOlder