Skip to content

Instantly share code, notes, and snippets.

View a-bronx's full-sized avatar

Andrey Bronnikov a-bronx

  • HID Global
  • Fremont, CA
View GitHub Profile
static class EnumerableExtensions
{
/* Zips an arbitrary number of collections.
Parameters:
* sources: a collection of collections to zip.
* resultSelector: a function to process every 'slice' of the zipper and produce a result object.
* stopOnFirstSource: when 'true', the method will stop zipping when any of sources exhausted;
otherwize it will continue zipping until all sources are exhauste
//-------------------------------------------------------------------
// Provides a "finally" lambda block for C++.
// Example:
//
// void ReenterableFunction() {
// static bool isActive = true; // static reenterability flag
//
// if (isActive) return; // check the flag
// auto reset = finally([&]{ isActive = false; }); // we need to reset the flag on exit, even if there was an exception in the code below.
// isActive = true; // set the flag and proceed