Giter VIP home page Giter VIP logo

scope-guard's Introduction

Scope Guard

CI GitHub release License C++

Implementation of Scope Guards (scope_exit, scope_success, scope_fail) and unique_resource as proposed in P0052R10.

Compatibility

This implementation conforms to P0052, except:

Namespace

The namespace sr is used instead of std.

Filenames

The filenames contain a .h extension. To enable the compatible header as specified in the document the CMake option SCOPEGUARD_ENABLE_COMPAT_HEADER can be used. This will generate and install an additional header named scope (without file extension).

Standardisation progress

P0052 has been adopted (2019-03) and is in the Library Fundamentals v3 now.

Documentation

License

MIT License

Copyright (c) 2017-2024 offa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

scope-guard's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scope-guard's Issues

List deviations of N3949

As sometimes N3949 isn't correct or unclear, there should be a list of deviations or implementation decisions.

Count executions not whether or not

Instead of testing for execution (executed yes / no) better test for the exact number of executions. As the former may hide multiple calls to the deleter.

Name space change

As the namespace contains all classes, not just scope guards, it should be changed to something more general. Eg. sr (Scoped Resource, the naming of the Proposal).

Clarify type requirements of operator->

The operator-> requires a type that satisfies (§ 8.4.1/11):

is_pointer<R>::value && (is_class<R>::value || is_union<R>::value)

This however doesn't work, R as either a Pointer type or a class / union.

Implement P0052

Implement P0052 (#26) instead of N3949.

  • Update project description (, labels, topics, etc.)
  • Update documentation
  • Implement / update new classes and functions
  • Update install targets
  • Implement scope Header (#31, #32)

Port the Move-Ctor

scope_exit does no longer need to be move assignable (see § 6.2 No. 3 and 5).

Update

It still has a move ctor and the operators remain deleted. Though the former needs some changes.

Create a C++17 branch?

Maybe it's a good idea to create a branch which uses C++17, as it then can utilize deducing ctors (see § 6.2 No. 4).

Improve call checks

Improve call checks in the tests. A mock framework should be used to replace all the annoying and badly maintainable manual work.

Implement scope Header

Implement scope Header as described in § 7.5.1.

Classes

  • scope_exit#33
  • scope_fail#34
  • scope_success#35
  • unique_resource#37

Factories

  • make_unique_resource_checked()#39
  • make_scope_exit()#36
  • make_scope_fail()#36
  • make_scope_success()#36
  • make_unique_resource()#39

Clarify return type of release() Method

Clarify the return type of release() Method as there are different specifications:

  • Specification (§ 8.4 and § 8.4.1): R&&
  • Example Implementation (§ 9.2): const R&

Add move-ctor

Add move-ctor, this is required by #4. The default one can not be used as it's necessary to release the move-from object.

Enhance documentation

Enhance documentation:

  • Compatibility to N3949 / Std
  • Installation – #11
  • Usage / Examples – Later, when #27 is done, for now see N3949 and tests
  • Contribution guide
  • Requirements – None, except C++14 and CMake

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.