SiddiqSoft.RunOnEnd 1.3.2

dotnet add package SiddiqSoft.RunOnEnd --version 1.3.2                
NuGet\Install-Package SiddiqSoft.RunOnEnd -Version 1.3.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.RunOnEnd" Version="1.3.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SiddiqSoft.RunOnEnd --version 1.3.2                
#r "nuget: SiddiqSoft.RunOnEnd, 1.3.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SiddiqSoft.RunOnEnd as a Cake Addin
#addin nuget:?package=SiddiqSoft.RunOnEnd&version=1.3.2

// Install SiddiqSoft.RunOnEnd as a Cake Tool
#tool nuget:?package=SiddiqSoft.RunOnEnd&version=1.3.2                

RunOnEnd : Run a lambda in destructor

Build Status alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Objective

  • A simpler "run on end" vs. the custom deletor available via std::unique_ptr<>. It is important to note that we do not provide an "owning" helper as this is better accomplished via the destructor code for std::unique_ptr<>.
  • Use the nuget SiddiqSoft.RunOnEnd
  • Copy paste..whatever works.

Usage

The utility can be used to ensure you cleanup within a scope, update some global variable or use the definition to build your own auto-cleanup.

Consider the following example where the utility UseWinsock builds on RunOnEnd for its functionality.

struct UseWinsock : private siddiqsoft::RunOnEnd
{
    UseWinsock() noexcept
        : m_rc(E_FAIL)
        , siddiqsoft::RunOnEnd([&]() {
            if (m_rc == S_OK) WSACleanup();
        })
    {
        ZeroMemory(&m_wsaData, sizeof(m_wsaData));
        m_rc = WSAStartup(MAKEWORD(2, 2), &m_wsaData);
        m_rc = (m_rc == 0) ? S_OK : WSAGetLastError();
    }

    operator bool() { return (m_rc == S_OK); }

private:
    int     m_rc;
    WSADATA m_wsaData;
};

Import

  • Use the SiddiqSoft.RunOnEnd nuget package.
  • Use CMP package import it into your project's CMakeLists
    CPMAddPackage("gh:SiddiqSoft/RunOnEnd#1.3.0");
    ..
    ..
    target_link_libraries(your-project PRIVATE runonend::runonend)

<small align="right">

© 2021-2024 Siddiq Software LLC. All rights reserved.

</small>

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SiddiqSoft.RunOnEnd:

Package Downloads
SiddiqSoft.AzureCppUtils

Azure REST API Helpers for Modern C++. Featuring helper functions for date-time, encryption tokens for Azure REST API as a single header-only package and native Win32 libraries.

SiddiqSoft.CosmosClient

Azure Cosmos REST-API Client for Modern C++

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.2 179 12/4/2024
1.3.1.1 448 12/3/2024
1.3.0 74 12/3/2024
1.2.1 931 11/20/2021
1.2.0 33,724 8/18/2021
1.1.1 358 7/30/2021
1.1.0 867 7/28/2021
1.0.3 338 7/28/2021
1.0.2 337 7/27/2021
1.0.1 425 7/27/2021
1.0.0 1,479 7/26/2021