[Libreoffice] [Patch][EasyHacks] Replace ScfNoCopy in calc with boost::noncopyable
Kohei Yoshida
kyoshida at novell.com
Wed Nov 10 10:18:04 PST 2010
Hello Nigel,
On Wed, 2010-11-10 at 17:12 +0000, Nigel Hawkins wrote:
> Hi,
>
> This should address the first item in the "removal of duplicate template
> classes in calc filter code" section from the easy hacks page.
>
> Not quite a simple search-and-replace but pretty close.
Yup, good work. :-) Just reviewed and committed as is.
> The second item (ScfNoInstance) is slightly more involved. All of the
> classes derived from ScfNoInstance are just collections of static
> methods and none of them are derived from. Since C++ doesn't support
> declaring classes as static, I'm thinking that converting those classes
> to namespaces is the correct route? (My C++ skills are a bit rusty).
You could make them non copyable first, then declare their constructor
private and leave the constructor undefined. This way when someone
tries to instantiate those classes the compiler would fail to link due
to undefined definition.
So, you could do stuff like
class SomeStaticClass : private boost::non_copyable
{
private:
SomeStaticClass(); // no definition, just declaration.
..
to make the class non-instantiable.
I wouldn't replace them with namespaces, but that's just my personal
preference & I don't see namespaces used like that in this code base.
HTH,
Kohei
>
> Nigel
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
--
Kohei Yoshida, LibreOffice hacker, Calc
<kyoshida at novell.com>
More information about the LibreOffice
mailing list