wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src scoped_resource.hpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src scoped_resource.hpp
Date: Sat, 04 Sep 2004 12:59:31 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/09/04 16:54:20

Modified files:
        src            : scoped_resource.hpp 

Log message:
        Nobody uses the features the release variable provides, just remove it 
(empty data member optimization is a urban legend)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/scoped_resource.hpp.diff?tr1=1.16&tr2=1.17&r1=text&r2=text

Patches:
Index: wesnoth/src/scoped_resource.hpp
diff -u wesnoth/src/scoped_resource.hpp:1.16 
wesnoth/src/scoped_resource.hpp:1.17
--- wesnoth/src/scoped_resource.hpp:1.16        Fri Aug  6 02:42:36 2004
+++ wesnoth/src/scoped_resource.hpp     Sat Sep  4 16:54:20 2004
@@ -1,4 +1,4 @@
-/* $Id: scoped_resource.hpp,v 1.16 2004/08/06 02:42:36 Sirp Exp $ */
+/* $Id: scoped_resource.hpp,v 1.17 2004/09/04 16:54:20 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -29,7 +29,7 @@
 * Usage example, for working with files:
 *
 * @code
-* struct close_file { void operator(int fd) const {close(fd);} };
+* struct close_file { void operator()(int fd) const {close(fd);} };
 * ...
 * {
 *    const scoped_resource<int,close_file> file(open("file.txt",O_RDONLY));
@@ -49,7 +49,6 @@
 class scoped_resource
 {
        T resource;
-       ReleasePolicy release;
 
        //prohibited operations
        scoped_resource(const scoped_resource&);
@@ -62,10 +61,9 @@
   * Constructor
        *
        * @ param res This is the resource to be managed
-       * @ param rel This is the functor to release the object
   */
-       scoped_resource(resource_type res=resource_type(),release_type 
rel=release_type())
-                       : resource(res), release(rel) {}
+       scoped_resource(resource_type res = resource_type())
+                       : resource(res) {}
 
   /**
   * The destructor is the main point in this class. It takes care of proper
@@ -73,7 +71,7 @@
        */
        ~scoped_resource()
        {
-               release(resource);
+               release_type()(resource);
        }
 
   /**
@@ -100,7 +98,7 @@
        resource_type operator->() const { return resource; }
 
        void assign(const resource_type& o) {
-               release(resource);
+               release_type()(resource);
                resource = o;
        }
 };




reply via email to

[Prev in Thread] Current Thread [Next in Thread]