From 4abd57dc2d44244a038796b174cbb64e6fd62e28 Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Thu, 18 Jul 2013 09:25:54 +0000 Subject: [PATCH] Use C++11 deleted functions feature if available. Implement DISALLOW_COPY_AND_ASSIGN and DISALLOW_IMPLICIT_CONSTRUCTORS using C++11 deleted functions if possible. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/19728003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15742 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/globals.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/globals.h b/src/globals.h index f00e676..e695e94 100644 --- a/src/globals.h +++ b/src/globals.h @@ -327,11 +327,18 @@ F FUNCTION_CAST(Address addr) { } +#if __cplusplus >= 201103L +#define DISALLOW_BY_DELETE = delete +#else +#define DISALLOW_BY_DELETE +#endif + + // A macro to disallow the evil copy constructor and operator= functions // This should be used in the private: declarations for a class -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&) DISALLOW_BY_DELETE; \ + void operator=(const TypeName&) DISALLOW_BY_DELETE // A macro to disallow all the implicit constructors, namely the @@ -341,7 +348,7 @@ F FUNCTION_CAST(Address addr) { // that wants to prevent anyone from instantiating it. This is // especially useful for classes containing only static methods. #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName(); \ + TypeName() DISALLOW_BY_DELETE; \ DISALLOW_COPY_AND_ASSIGN(TypeName) -- 2.7.4