basedOpinionated utility library |
git clone git://git.dimitrijedobrota.com/based.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |
template.cpp (690B)
0 #include <functional> 1 #include <iostream> 2 3 #include "based/template.hpp" 4 5 int main() 6 { 7 { 8 const auto func = based::overload { 9 [](const int* integer) 10 { 11 std::cout << "i=" << *integer << '\n'; 12 }, 13 [](const double* dbl) 14 { 15 std::cout << "d=" << *dbl << '\n'; 16 } 17 }; 18 19 const int integer = 5; 20 func(&integer); 21 22 const double dbl = 7.3; 23 func(&dbl); 24 } 25 26 { 27 const based::function func = [](int val) 28 { 29 return val + 1; 30 }; 31 std::cout << func(3) << '\n'; 32 } 33 34 { 35 const std::function func = [](int val) 36 { 37 return val + 1; 38 }; 39 std::cout << func(3) << '\n'; 40 } 41 42 return 0; 43 }