I want to get rid of those parts of boost that have an
exceptionally bad overhead.

Patch to replace boost::noncopyable with a homemade version attached. 

This is to avoid a discussion on the "expressiveness" of 

        #include "something"

        class Foo : NonCopiable {
                ...
        };

vs

        class Foo {
                ...
        private:
                // make class noncopyable: unintentionally no implemented
                Foo(Foo const &);
                Foo & operator=(Foo const &);
        };

I actually prefer the latter, but the former is closer to the 
boost::noncopyable version we have right now.

In any case I want to get rid of #include <boost/utility> which we only
use for boost::noncopyable (i.e. < 10 lines) It pulls in 30000 lines of
otherwise mainly useless code which ends up thanks to its use in
BufferView.h in almost all of our translation units.

Andre'
Index: BufferList.h
===================================================================
--- BufferList.h        (revision 20587)
+++ BufferList.h        (working copy)
@@ -14,7 +14,7 @@
 
 #include "support/docstring.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <vector>
 
@@ -28,7 +28,7 @@
  * The class holds all all open buffers, and handles construction
  * and deletions of new ones.
  */
-class BufferList : boost::noncopyable {
+class BufferList : NonCopyable {
 public:
        typedef std::vector<Buffer *>::iterator iterator;
        typedef std::vector<Buffer *>::const_iterator const_iterator;
Index: insets/ExternalTemplate.h
===================================================================
--- insets/ExternalTemplate.h   (revision 20587)
+++ insets/ExternalTemplate.h   (working copy)
@@ -15,7 +15,7 @@
 
 #include "ExternalTransforms.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 namespace lyx {
 
@@ -97,7 +97,7 @@
 /**
  *  A singleton class that manages the external inset templates
  */
-class TemplateManager : boost::noncopyable {
+class TemplateManager : NonCopyable {
 public:
        /// Map from the LyX name of the template to the template structure
        typedef std::map<std::string, Template> Templates;
Index: graphics/GraphicsCacheItem.h
===================================================================
--- graphics/GraphicsCacheItem.h        (revision 20587)
+++ graphics/GraphicsCacheItem.h        (working copy)
@@ -30,7 +30,7 @@
 
 #include "GraphicsTypes.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/signal.hpp>
 
@@ -45,7 +45,7 @@
 class Converter;
 
 /// A lyx::graphics::Cache item holder.
-class CacheItem : boost::noncopyable {
+class CacheItem : NonCopyable {
 public:
        ///
        CacheItem(support::FileName const & file);
Index: graphics/Previews.h
===================================================================
--- graphics/Previews.h (revision 20587)
+++ graphics/Previews.h (working copy)
@@ -15,7 +15,7 @@
 #ifndef PREVIEWS_H
 #define PREVIEWS_H
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/scoped_ptr.hpp>
 
 namespace lyx {
@@ -27,7 +27,7 @@
 
 class PreviewLoader;
 
-class Previews : boost::noncopyable {
+class Previews : NonCopyable {
 public:
        /// a wrapper for lyxrc.preview
        static LyXRC_PreviewStatus status();
Index: graphics/PreviewLoader.h
===================================================================
--- graphics/PreviewLoader.h    (revision 20587)
+++ graphics/PreviewLoader.h    (working copy)
@@ -18,7 +18,7 @@
 #ifndef PREVIEWLOADER_H
 #define PREVIEWLOADER_H
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/signal.hpp>
 
@@ -31,7 +31,7 @@
 
 class PreviewImage;
 
-class PreviewLoader : boost::noncopyable {
+class PreviewLoader : NonCopyable {
 public:
        /** We need buffer because we require the preamble to the
         *  LaTeX file.
Index: graphics/GraphicsCache.h
===================================================================
--- graphics/GraphicsCache.h    (revision 20587)
+++ graphics/GraphicsCache.h    (working copy)
@@ -20,7 +20,7 @@
 #ifndef GRAPHICSCACHE_H
 #define GRAPHICSCACHE_H
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 
@@ -36,7 +36,7 @@
 
 class CacheItem;
 
-class Cache : boost::noncopyable {
+class Cache : NonCopyable {
 public:
 
        /// This is a singleton class. Get the instance.
Index: graphics/GraphicsConverter.h
===================================================================
--- graphics/GraphicsConverter.h        (revision 20587)
+++ graphics/GraphicsConverter.h        (working copy)
@@ -19,7 +19,7 @@
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/signal.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 namespace lyx {
 
@@ -27,7 +27,7 @@
 
 namespace graphics {
 
-class Converter : boost::noncopyable {
+class Converter : NonCopyable {
 public:
        /// Can the conversion be performed?
        static bool isReachable(std::string const & from_format_name,
Index: LyXAction.h
===================================================================
--- LyXAction.h (revision 20587)
+++ LyXAction.h (working copy)
@@ -15,7 +15,7 @@
 
 #include "lfuns.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <map>
 #include <string>
@@ -32,7 +32,7 @@
  * dynamically, for encapsulating a real action and an
  * argument. They are used for things like the menus.
  */
-class LyXAction : boost::noncopyable {
+class LyXAction : NonCopyable {
 private:
        /// information for an action
        struct func_info {
Index: Session.h
===================================================================
--- Session.h   (revision 20587)
+++ Session.h   (working copy)
@@ -16,7 +16,7 @@
 #include "support/FileName.h"
 #include "support/types.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/tuple/tuple.hpp>
 
 #include <string>
@@ -38,7 +38,7 @@
 
 /** base class for all sections in the session file
 */
-class SessionSection : boost::noncopyable {
+class SessionSection : NonCopyable {
 
 public:
        ///
@@ -372,7 +372,7 @@
 };
 
 
-class Session : boost::noncopyable {
+class Session : NonCopyable {
 
 public:
        /** Read the session file.
Index: TextClassList.h
===================================================================
--- TextClassList.h     (revision 20587)
+++ TextClassList.h     (working copy)
@@ -16,7 +16,7 @@
 
 #include "support/types.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <string>
 #include <vector>
@@ -30,7 +30,7 @@
 extern bool LyXSetStyle();
 
 ///
-class TextClassList : boost::noncopyable {
+class TextClassList : NonCopyable {
 public:
        ///
        typedef std::vector<TextClass> ClassList;
Index: frontends/WorkArea.cpp
===================================================================
--- frontends/WorkArea.cpp      (revision 20587)
+++ frontends/WorkArea.cpp      (working copy)
@@ -38,7 +38,7 @@
 #include "support/ForkedcallsController.h"
 #include "support/FileName.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/bind.hpp>
 #include <boost/current_function.hpp>
 
Index: frontends/LyXView.h
===================================================================
--- frontends/LyXView.h (revision 20587)
+++ frontends/LyXView.h (working copy)
@@ -18,7 +18,7 @@
 
 #include <boost/signal.hpp>
 #include <boost/signals/trackable.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <vector>
 
@@ -54,7 +54,7 @@
  * Additionally we would like to support multiple views
  * in a single LyXView.
  */
-class LyXView : public boost::signals::trackable, boost::noncopyable {
+class LyXView : public boost::signals::trackable, NonCopyable {
 public:
        ///
        LyXView(int id);
Index: frontends/Dialogs.h
===================================================================
--- frontends/Dialogs.h (revision 20587)
+++ frontends/Dialogs.h (working copy)
@@ -14,7 +14,7 @@
 #define DIALOGS_H
 
 #include <boost/signal.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <map>
 
@@ -29,7 +29,7 @@
 
 /** Container of all dialogs.
  */
-class Dialogs : boost::noncopyable {
+class Dialogs : NonCopyable {
 public:
        ///
        Dialogs(LyXView &);
Index: frontends/qt4/pch.h
===================================================================
--- frontends/qt4/pch.h (revision 20587)
+++ frontends/qt4/pch.h (working copy)
@@ -10,7 +10,7 @@
 #include <boost/signals/trackable.hpp>
 #include <boost/signal.hpp>
 #include <boost/tuple/tuple.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <algorithm>
 #include <cmath>
Index: support/RandomAccessList.h
===================================================================
--- support/RandomAccessList.h  (revision 20587)
+++ support/RandomAccessList.h  (working copy)
@@ -15,7 +15,7 @@
 
 //#include "debug.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <vector>
 #include <list>
Index: support/FileMonitor.h
===================================================================
--- support/FileMonitor.h       (revision 20587)
+++ support/FileMonitor.h       (working copy)
@@ -15,7 +15,7 @@
 #ifndef FILEMONITOR_H
 #define FILEMONITOR_H
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/signal.hpp>
 
@@ -24,7 +24,7 @@
 
 class FileName;
 
-class FileMonitor : boost::noncopyable {
+class FileMonitor : NonCopyable {
 public:
        /** Once monitoring begins, the file will be monitored every
         *  interval ms.
Index: support/pch.h
===================================================================
--- support/pch.h       (revision 20587)
+++ support/pch.h       (working copy)
@@ -19,7 +19,7 @@
 #endif
 
 #include <boost/tokenizer.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <fcntl.h>
 #ifdef HAVE_SYS_STAT_H
Index: support/docstring.h
===================================================================
--- support/docstring.h (revision 20587)
+++ support/docstring.h (working copy)
@@ -10,8 +10,8 @@
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef LYX_DOCSTRING_H
-#define LYX_DOCSTRING_H
+#ifndef DOCSTRING_H
+#define DOCSTRING_H
 
 #include "support/types.h"
 
@@ -66,34 +66,34 @@
 docstring const normalize_c(docstring const & s);
 
 /// Compare a docstring with a C string of ASCII characters
-bool operator==(lyx::docstring const &, char const *);
+bool operator==(docstring const &, char const *);
 
 /// Compare a C string of ASCII characters with a docstring
-inline bool operator==(char const * l, lyx::docstring const & r) { return r == 
l; }
+inline bool operator==(char const * l, docstring const & r) { return r == l; }
 
 /// Compare a docstring with a C string of ASCII characters
-inline bool operator!=(lyx::docstring const & l, char const * r) { return !(l 
== r); }
+inline bool operator!=(docstring const & l, char const * r) { return !(l == 
r); }
 
 /// Compare a C string of ASCII characters with a docstring
-inline bool operator!=(char const * l, lyx::docstring const & r) { return !(r 
== l); }
+inline bool operator!=(char const * l, docstring const & r) { return !(r == 
l); }
 
 /// Concatenate a docstring and a C string of ASCII characters
-lyx::docstring operator+(lyx::docstring const &, char const *);
+docstring operator+(docstring const &, char const *);
 
 /// Concatenate a C string of ASCII characters and a docstring
-lyx::docstring operator+(char const *, lyx::docstring const &);
+docstring operator+(char const *, docstring const &);
 
 /// Concatenate a docstring and a single ASCII character
-lyx::docstring operator+(lyx::docstring const & l, char r);
+docstring operator+(docstring const & l, char r);
 
 /// Concatenate a single ASCII character and a docstring
-lyx::docstring operator+(char l, lyx::docstring const & r);
+docstring operator+(char l, docstring const & r);
 
 /// Append a C string of ASCII characters to a docstring
-lyx::docstring & operator+=(lyx::docstring &, char const *);
+docstring & operator+=(docstring &, char const *);
 
 /// Append a single ASCII character to a docstring
-lyx::docstring & operator+=(lyx::docstring & l, char r);
+docstring & operator+=(docstring & l, char r);
 
 } // namespace lyx
 
Index: support/Path.h
===================================================================
--- support/Path.h      (revision 20587)
+++ support/Path.h      (working copy)
@@ -14,7 +14,7 @@
 
 #include "support/FileName.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <string>
 
@@ -34,7 +34,7 @@
  *
  * At the end of p's scope the cwd is reset to its previous value.
  */
-class Path : boost::noncopyable {
+class Path : NonCopyable {
 public:
        /// change to the given directory
        explicit Path(FileName const & path);
Index: support/utility.h
===================================================================
--- support/utility.h   (revision 0)
+++ support/utility.h   (revision 0)
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+/**
+ * \file utility.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * Provide a set of typedefs for commonly used things like sizes and
+ * indices wile trying to stay compatible with types used
+ * by the standard containers.
+ *
+ * \author Andr� P�nitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef UTILITY_H
+#define UTILITY_H
+
+// This is mainly a replacement for stuff that's too expensive in boost.
+
+namespace lyx {
+
+class NonCopyable
+{
+public:
+       NonCopyable() {}
+private:
+       // intentionally unimplemented
+       NonCopyable(NonCopyable const &);
+       void operator=(NonCopyable const &);
+};
+
+
+template <typename T>
+class ScopedPtr : public NonCopyable
+{
+public:
+       ScopedPtr() : ptr_(0) {}
+       explicit ScopedPtr(T * ptr) : ptr_(ptr) {}
+       ~ScopedPtr() { delete ptr_; }
+       T * get() const { return ptr_; }
+private:
+       T * ptr_;
+};
+
+} // namespace lyx
+
+#endif // UTILITY_H
Index: LaTeX.h
===================================================================
--- LaTeX.h     (revision 20587)
+++ LaTeX.h     (working copy)
@@ -19,7 +19,7 @@
 #include "support/docstring.h"
 #include "support/FileName.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/signal.hpp>
 
 #include <vector>
@@ -93,7 +93,7 @@
  * This is required by the LaTeX compiler, and we also make use of it by
  * various support::makeAbsPath() calls.
  */
-class LaTeX : boost::noncopyable {
+class LaTeX : NonCopyable {
 public:
        /** Return values from scanLogFile() and run() (to come)
 
Index: pch.h
===================================================================
--- pch.h       (revision 20587)
+++ pch.h       (working copy)
@@ -18,7 +18,7 @@
 #include <boost/signals/trackable.hpp>
 #include <boost/tokenizer.hpp>
 #include <boost/tuple/tuple.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/version.hpp>
 
 #include <algorithm>
Index: ConverterCache.h
===================================================================
--- ConverterCache.h    (revision 20587)
+++ ConverterCache.h    (working copy)
@@ -21,7 +21,7 @@
 #ifndef CONVERTERCACHE_H
 #define CONVERTERCACHE_H
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/scoped_ptr.hpp>
 
 #include <string>
@@ -49,7 +49,7 @@
  *
  * There is no cache maintenance yet (max size, max age etc.)
  */
-class ConverterCache : boost::noncopyable {
+class ConverterCache : NonCopyable {
 public:
 
        /// This is a singleton class. Get the instance.
Index: BufferView.h
===================================================================
--- BufferView.h        (revision 20587)
+++ BufferView.h        (working copy)
@@ -24,7 +24,7 @@
 #include "support/types.h"
 
 #include <boost/tuple/tuple.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 #include <boost/signal.hpp>
 
 #include <utility>
@@ -85,7 +85,7 @@
  * \sa Buffer
  * \sa CoordCache
  */
-class BufferView : boost::noncopyable {
+class BufferView : NonCopyable {
 public:
        ///
        BufferView(Buffer & buffer);
Index: LyX.h
===================================================================
--- LyX.h       (revision 20587)
+++ LyX.h       (working copy)
@@ -15,7 +15,7 @@
 #define LYX_H
 
 #include <boost/scoped_ptr.hpp>
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <string>
 
@@ -47,7 +47,7 @@
 }
 
 /// initial startup
-class LyX : boost::noncopyable {
+class LyX : NonCopyable {
 public:
 
        LyX();
Index: ModuleList.h
===================================================================
--- ModuleList.h        (revision 20587)
+++ ModuleList.h        (working copy)
@@ -15,7 +15,7 @@
 #include <vector>
 #include "support/FileName.h"
 
-#include <boost/utility.hpp>
+#include "support/utility.h"
 
 #include <map>
 
@@ -45,7 +45,7 @@
         *  The ModuleList represents the various LyXModule's that are 
available at
         *  present.
         */
-       class ModuleList : boost::noncopyable {
+       class ModuleList : NonCopyable {
                public:
                        /// reads the modules from a file generated by 
configure.py
                        bool load();

Reply via email to