Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On 08/31/2012 03:59 PM, Libreoffice Gerrit user wrote:
New commits:
commit 574ddaba5315816a5629550a0a12f9c694b79370
Author: Zolnai Tamás <zolnaitamas2000@gmail.com>
Date:   Fri Aug 31 14:40:14 2012 +0200

     Make Regexpr class safer

     Make copy constructor and copy operator private

     Change-Id: Ifdaff6d74bebb0406432d470c84d221f2c06ba94
     Reviewed-on: https://gerrit.libreoffice.org/519
     Reviewed-by: Andras Timar <atimar@suse.com>
     Tested-by: Andras Timar <atimar@suse.com>

diff --git a/regexp/inc/regexp/reclass.hxx b/regexp/inc/regexp/reclass.hxx
index f61112d..4be52bb 100644
--- a/regexp/inc/regexp/reclass.hxx
+++ b/regexp/inc/regexp/reclass.hxx
@@ -357,6 +357,9 @@ class REGEXP_DLLPUBLIC Regexpr
      sal_Bool iswordend(const sal_Unicode *d, sal_Unicode *string, sal_Int32 ssize);
      void set_list_bit(sal_Unicode c, sal_Unicode *b);

+    Regexpr(const Regexpr&);
+    Regexpr& operator=(const Regexpr&);
+
  public:
      // constructors
      Regexpr( const ::com::sun::star::util::SearchOptions & rOptions,

FYI, the standard idiom is to privately derive the class from boost::noncopyable instead.

One general advantage of doing it that way is that at least with Clang 3.2 --std=c++11, it does not prevent the compiler from flagging a class's unused private fields in a compilation unit that sees definitions for all of that class's declared member functions. That is,

  class Foo: private boost::noncopyable {
    int n;
  public:
    Foo() {}
  };

will cause

  warning: private field 'n' is not used [-Wunused-private-field]

 while

  class Foo {
    int n;
    Foo(Foo const &);
  public:
    Foo() {}

will not.

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.