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 <iostream> | |
| #include <functional> | |
| using signa = bool(void *); | |
| using functo_signa = std::function<bool(void *, int)>; | |
| template <typename Signature> | |
| struct wrapper; | |
| template <typename Ret, typename... Args> | 
  
    
      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<class InputIt, class T> | |
| T accumulate(InputIt first, InputIt last, T init) | |
| { | |
| for (; first != last; ++first) { | |
| init = init + *first; | |
| } | |
| return init; | |
| } | |
| template<class InputIt, class T, class BinaryOperation> | 
  
    
      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
    
  
  
    
  | std::vector<int> vi{ 1,2,3,4,5,6,7,8,9,10 }; | |
| using namespace ranges; | |
| // we combine two views - remove_if and transform to produce a new composition | |
| auto evensToStrings = view::remove_if([](int i) {return i % 2 == 1; }) | |
| | view::transform([](int i) {return std::to_string(i); }); | |
| // than we applay the new compositon to the range, currently a vector | |
| auto rng = vi | evensToStrings; | 
  
    
      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
    
  
  
    
  | std :: vector < int > vec {2, 5, 3, 1, 4}; | |
| std :: sort (vec.begin () vec.end ()); | |
| std :: sort (vec); | 
  
    
      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
    
  
  
    
  | std::bitset<8> b1(0b11'11'00'00); | |
| // when indexing remember ^ this is bit [0] | |
| std::bitset<8> b2("00001111"); | |
| // PROPOSAL OPPORTUNITY - you can`t initialize it with a string "00'00'11'11" | |
| auto b3 = b1 & b2; | |
| b3 |= b3; | |
| b3[0] = true; | |
| std::cout << "Bitsets!\n" << b1.to_string() << '\n' | 
  
    
      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
    
  
  
    
  | struct A { | |
| A(int) { } // converting constructor | |
| }; | |
| struct B { | |
| explicit B(int) { } // non-converting constructor | |
| }; | |
| void foo(A a) {} | 
  
    
      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
    
  
  
    
  | valarray<int> va1(5); // create with 10 elements | |
| valarray<int> va2(5); // create with 10 elements | |
| for (int i=0; i < 5; i++) { | |
| va1[i] = i; | |
| va2[i] = i * 2; | |
| } | |
| valarray<int> vaMult = va1 * va2; | |
  
    
      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
    
  
  
    
  | auto foo() -> int; | |
| auto moo(int a, int b) -> double; | |
| auto sum(const std::vector<int>& numbers) -> long int; | 
  
    
      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<class T, class U> | |
| auto add(T t, U u) -> decltype(t + u) // the return type is the type of operator+(T, U) | |
| { | |
| return t + u; | |
| } | 
  
    
      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, typename U> | |
| concept bool Equality_comparable = | |
| requires (T a, U b) { | |
| { a == b } -> bool; // compare T == U | |
| { a != b } -> bool; // compare T != U | |
| { b == a } -> bool; // compare U == T | |
| { b != a } -> bool; // compare U != T | |
| }; | |
| template<typename T> | 
NewerOlder