profile image

Nafis Ayaz

C++ Software Engineer

Scope Utilities

  • Pipeline is a small and effective functionalities, written in C++17. rovides many pipeline functions that can be used in both C++ standard libraries like std::list , std::vector , and also xperimental datastructures like xperimental::list_sm , xperimental::array_sm and so on. . It's fast and concise, increases industrial productivity.

    Objectives are:

  • Concise and yet readable
  • Dynamic memory management
  • Productivity

  • Scope:

    #include<iostream> #include<xperimental/scope/scope.h++> int* test(){   int* n = new int(100);   auto cleanup = xperimental::make_scope_exit([&n]()mutable{ delete n; n=nullptr; });   std::cout<< "m = " << *m << "\n";   return n; }// deletes the pointer when it goes out of scope int main(){   int* m = test(); // Runtime error }

    Output:

    n = 100

    xperimental::from is applicable of any primitive data-types: int , float, std::string and xperimental datastructures like: xperimental::array of any data-type, xperimental::filter and xperimental::transform can take Lambda expression and Callable object that creates objects if there is no further pipe after that otherwise return data. Returned result is xperimental::array<int>

    #include<iostream> #include<xperimental/scope/scope.h++> int* test(){   int* n = new int(100);   auto cleanup = xperimental::cleanup(n);   std::cout<< "n = " << *n << "\n";   return n; }// deletes the pointer when it goes out of scope int main(){   int* m = test(); // Runtime error }

    Output:

    n = 100

    xperimental::from is applicable of any primitive data-types: int , float, std::string and xperimental datastructures like: xperimental::array of any data-type, xperimental::filter and xperimental::transform can take Lambda expression and Callable object that creates objects if there is no further pipe after that otherwise return data. Returned result is xperimental::array<int>

    #include<iostream> #include<xperimental/scope/smart_ptr.h++> int main(){   auto ptr = xperimental::make_smart_ptr(new int(100));   std::cout<< "value = " << ptr << "\n";   ptr = 20;   std::cout<< "value = " << ptr << "\n";   ++ptr;   std::cout<< "value = " << ptr << "\n"; }// deletes the pointer when it goes out of scope

    Output:

    value = 100

    value = 20

    value = 21

    xperimental::from is applicable of any primitive data-types: int , float, std::string and xperimental datastructures like: xperimental::array of any data-type, xperimental::filter and xperimental::transform can take Lambda expression and Callable object that creates objects if there is no further pipe after that otherwise return data. Returned result is xperimental::array<int>