From 8f7c3b42d7b2bf1ae5ebaab65fc7c20dfbbaf827 Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Thu, 26 Oct 2006 10:58:19 +0000 Subject: [PATCH] ove macro values into Loki namespace git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@769 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/ConstPolicy.h | 2 +- include/loki/ScopeGuard.h | 4 ++-- include/loki/SmallObj.h | 2 +- test/ScopeGuard/main.cpp | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/loki/ConstPolicy.h b/include/loki/ConstPolicy.h index b5e2383..acd3b91 100644 --- a/include/loki/ConstPolicy.h +++ b/include/loki/ConstPolicy.h @@ -53,7 +53,7 @@ namespace Loki // default will not break existing code #ifndef LOKI_DEFAULT_CONSTNESS -#define LOKI_DEFAULT_CONSTNESS DontPropagateConst +#define LOKI_DEFAULT_CONSTNESS ::Loki::DontPropagateConst #endif } // end namespace Loki diff --git a/include/loki/ScopeGuard.h b/include/loki/ScopeGuard.h index aaf1cdf..2c695e4 100644 --- a/include/loki/ScopeGuard.h +++ b/include/loki/ScopeGuard.h @@ -358,8 +358,8 @@ namespace Loki #define LOKI_CONCATENATE(s1, s2) LOKI_CONCATENATE_DIRECT(s1, s2) #define LOKI_ANONYMOUS_VARIABLE(str) LOKI_CONCATENATE(str, __LINE__) -#define LOKI_ON_BLOCK_EXIT ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard -#define LOKI_ON_BLOCK_EXIT_OBJ ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard +#define LOKI_ON_BLOCK_EXIT ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeGuard +#define LOKI_ON_BLOCK_EXIT_OBJ ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeObjGuard #endif // end file guardian diff --git a/include/loki/SmallObj.h b/include/loki/SmallObj.h index 8f7dab5..2fecd29 100644 --- a/include/loki/SmallObj.h +++ b/include/loki/SmallObj.h @@ -37,7 +37,7 @@ #endif #ifndef LOKI_DEFAULT_SMALLOBJ_LIFETIME -#define LOKI_DEFAULT_SMALLOBJ_LIFETIME LongevityLifetime::DieAsSmallObjectParent +#define LOKI_DEFAULT_SMALLOBJ_LIFETIME ::Loki::LongevityLifetime::DieAsSmallObjectParent #endif #if defined(LOKI_SMALL_OBJECT_USE_NEW_ARRAY) && defined(_MSC_VER) diff --git a/test/ScopeGuard/main.cpp b/test/ScopeGuard/main.cpp index 9719d99..4c9ca09 100644 --- a/test/ScopeGuard/main.cpp +++ b/test/ScopeGuard/main.cpp @@ -43,6 +43,7 @@ public: void AddFriend(User& newFriend); void AddFriendGuarded(User& newFriend); + void AddFriendGuardedMacros(User& newFriend); size_t countFriends(); @@ -84,6 +85,12 @@ void User::AddFriendGuarded(User& newFriend) guardRef.Dismiss(); } +void User::AddFriendGuardedMacros(User&) +{ + LOKI_ON_BLOCK_EXIT_OBJ(friends_, &UserCont::pop_back); (void) LOKI_ANONYMOUS_VARIABLE(scopeGuard); + LOKI_ON_BLOCK_EXIT(Decrement, Loki::ByRef(fCount)); (void) LOKI_ANONYMOUS_VARIABLE(scopeGuard); +} + int main() {