PageRenderTime 20ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/c++/cPlusPlusPlayground/cPlusPlusPlayground/cPlusPlusPlayground.cpp

https://github.com/diegopacheco/Diego-Pacheco-Sandbox
C++ | 48 lines | 31 code | 9 blank | 8 comment | 1 complexity | 9087f3acd09e1a4c108adf90b915b51d MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0, BSD-3-Clause, Unlicense
  1. // cPlusPlusPlayground.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include "CppLinq\cpplinq.hpp"
  5. #include <iostream>
  6. using namespace std;
  7. // https://cpplinq.codeplex.com/wikipage?title=LINQ%20for%20C%2b%2b%20-%20getting%20started&referringTitle=Home
  8. int computes_a_sum() {
  9. using namespace cpplinq;
  10. int ints[] = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 4 };
  11. auto result = from_array(ints)
  12. >> where([](int i) {return i % 2 == 0; }) // Keep only even numbers
  13. >> sum() // Sum remaining numbers
  14. ;
  15. return result;
  16. }
  17. int main(){
  18. // Linq for c++
  19. std::cout << "Linq C++ => " << computes_a_sum();
  20. // IFs, While, For
  21. StdCBasic_H::StdCBasic basic;
  22. basic.doWork();
  23. basic.doWorkSwicth();
  24. basic.doWorkWhile();
  25. basic.doWorkFor();
  26. // Structs, Classes, Contructors
  27. StructBasic_H::StructBasic structbasic;
  28. structbasic.doWork();
  29. structbasic.doWorkArrays();
  30. structbasic.doWorkStrings();
  31. structbasic.doWorkWithReferences();
  32. // + override
  33. Centavos_H::Centavos centavos(0);
  34. centavos.doWork();
  35. //Threads
  36. Threads_H::ThreadFun tf;
  37. tf.doWork();
  38. return 0;
  39. }