From 141d3f50d3b1e2053541c142e288a8441543e984 Mon Sep 17 00:00:00 2001 From: Dirk Stolle Date: Thu, 20 Mar 2025 15:58:29 +0100 Subject: [PATCH] Add support for header --- include/nonstd/scope.hpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/include/nonstd/scope.hpp b/include/nonstd/scope.hpp index 83ed338..44d1ab8 100644 --- a/include/nonstd/scope.hpp +++ b/include/nonstd/scope.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2020-2020 Martin Moene +// Copyright (c) 2020-2025 Martin Moene // // https://github.com/martinmoene/scope-lite // @@ -77,24 +77,21 @@ #if scope_CPP20_OR_GREATER && defined(__has_include ) # if __has_include( ) # define scope_HAVE_STD_SCOPE 1 +# define scope_HAVE_EXP_SCOPE 0 # elif __has_include( ) -# define scope_HAVE_STD_SCOPE 1 +# define scope_HAVE_STD_SCOPE 0 +# define scope_HAVE_EXP_SCOPE 1 # else # define scope_HAVE_STD_SCOPE 0 +# define scope_HAVE_EXP_SCOPE 0 # endif #else # define scope_HAVE_STD_SCOPE 0 +# define scope_HAVE_EXP_SCOPE 0 #endif #define scope_USES_STD_SCOPE ( (scope_CONFIG_SELECT_SCOPE == scope_SCOPE_STD) || ((scope_CONFIG_SELECT_SCOPE == scope_SCOPE_DEFAULT) && scope_HAVE_STD_SCOPE) ) - -// -// Using std : -// -// ToDo: -// - choose or . -// - use correct namespace in using below. -// +#define scope_USES_EXP_SCOPE ( (scope_CONFIG_SELECT_SCOPE == scope_SCOPE_STD) || ((scope_CONFIG_SELECT_SCOPE == scope_SCOPE_DEFAULT) && scope_HAVE_EXP_SCOPE) ) #if scope_USES_STD_SCOPE @@ -113,6 +110,23 @@ namespace nonstd using std::make_unique_resource_checked; } +#elif scope_USES_EXP_SCOPE + +#include + +namespace nonstd +{ + using std::experimental::scope_exit; + using std::experimental::scope_fail; + using std::experimental::scope_success; + using std::experimental::unique_resource; + + using std::experimental::make_scope_exit; + using std::experimental::make_scope_fail; + using std::experimental::make_scope_success; + using std::experimental::make_unique_resource_checked; +} + #else // scope_USES_STD_SCOPE // half-open range [lo..hi):