Create scoped_cptr to replace scoped_ptr_sfree
authorRoland Schulz <roland@utk.edu>
Fri, 17 Oct 2014 06:29:15 +0000 (02:29 -0400)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 20 Oct 2014 15:29:25 +0000 (17:29 +0200)
Compareed to the previous scoped_ptr_sfree, scoped_cptr has a get
method, a bool-conversion, and allows to specify a custom deleter.

If just a guard is required then the scoped_guard_sfree typedef
can be used which doesn't require to specify a type.

Change-Id: I81cb50c4cf34e2d5a93e9c4b0043afcbc5feb535

cmake/gmxTestCXX11.cmake
src/gromacs/selection/parser.cpp
src/gromacs/selection/parser.y
src/gromacs/trajectoryanalysis/modules/sasa.cpp
src/gromacs/trajectoryanalysis/modules/select.cpp
src/gromacs/utility/scoped_cptr.h [moved from src/gromacs/utility/scoped_ptr_sfree.h with 70% similarity]

index eaa8888e48adaac75fec32ac6e292130000ceccb..b20f86fc4c1058a3888ebb3d322ed967c695c748 100644 (file)
@@ -59,6 +59,7 @@ struct VarList {
   typedef VarList<Tail...> VarListTail;
   typedef std::pair<Head, typename VarListTail::ListType> ListType;
 };
+class a { explicit operator bool() {return true;} };
 int main() {
   typedef std::unique_ptr<int> intPointer;
   intPointer p(new int(10));
index b0beaa649c19433a12e6915f5b0e046566bfeb00..536ee2a5d7bb3db03010f61a587cc9dfbf26813a 100644 (file)
 /* Line 371 of yacc.c  */
 #line 56 "parser.y"
 
-#include "gromacs/utility/scoped_ptr_sfree.h"
+#include "gromacs/utility/scoped_cptr.h"
 
 #include "parser_internal.h"
 
-using gmx::scoped_ptr_sfree;
+using gmx::scoped_guard_sfree;
 using gmx::SelectionParserValue;
 using gmx::SelectionParserValueList;
 using gmx::SelectionParserValueListPointer;
@@ -1975,7 +1975,7 @@ yyreduce:
 #line 252 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(1) - (1)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(1) - (1)].str));
                  SelectionTreeElementPointer s
                         = _gmx_sel_init_group_by_name((yyvsp[(1) - (1)].str), scanner);
                  SelectionTreeElementPointer p
@@ -2001,7 +2001,7 @@ yyreduce:
 #line 270 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(1) - (2)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(1) - (2)].str));
                  set((yyval.sel), _gmx_sel_init_selection((yyvsp[(1) - (2)].str), get((yyvsp[(2) - (2)].sel)), scanner));
                  END_ACTION;
              }
@@ -2012,7 +2012,7 @@ yyreduce:
 #line 277 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_assign_variable((yyvsp[(1) - (3)].str), get((yyvsp[(3) - (3)].sel)), scanner));
                  END_ACTION;
              }
@@ -2023,7 +2023,7 @@ yyreduce:
 #line 284 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_assign_variable((yyvsp[(1) - (3)].str), get((yyvsp[(3) - (3)].sel)), scanner));
                  END_ACTION;
              }
@@ -2034,7 +2034,7 @@ yyreduce:
 #line 291 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_assign_variable((yyvsp[(1) - (3)].str), get((yyvsp[(3) - (3)].sel)), scanner));
                  END_ACTION;
              }
@@ -2178,7 +2178,7 @@ yyreduce:
 #line 383 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree opGuard((yyvsp[(2) - (3)].str));
+                 scoped_guard_sfree opGuard((yyvsp[(2) - (3)].str));
                  set((yyval.sel), _gmx_sel_init_comparison(get((yyvsp[(1) - (3)].sel)), get((yyvsp[(3) - (3)].sel)), (yyvsp[(2) - (3)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2190,7 +2190,7 @@ yyreduce:
 #line 394 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(2) - (2)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(2) - (2)].str));
                  set((yyval.sel), _gmx_sel_init_group_by_name((yyvsp[(2) - (2)].str), scanner));
                  END_ACTION;
              }
@@ -2241,7 +2241,7 @@ yyreduce:
 #line 422 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (2)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (2)].str));
                  set((yyval.sel), _gmx_sel_init_keyword((yyvsp[(2) - (2)].meth), SelectionParserValueListPointer(), (yyvsp[(1) - (2)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2253,7 +2253,7 @@ yyreduce:
 #line 430 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_init_keyword_strmatch((yyvsp[(2) - (3)].meth), gmx::eStringMatchType_Auto, get((yyvsp[(3) - (3)].vlist)), (yyvsp[(1) - (3)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2265,7 +2265,7 @@ yyreduce:
 #line 438 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (4)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (4)].str));
                  set((yyval.sel), _gmx_sel_init_keyword_strmatch((yyvsp[(2) - (4)].meth), (yyvsp[(3) - (4)].smt), get((yyvsp[(4) - (4)].vlist)), (yyvsp[(1) - (4)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2277,7 +2277,7 @@ yyreduce:
 #line 446 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_init_keyword((yyvsp[(2) - (3)].meth), get((yyvsp[(3) - (3)].vlist)), (yyvsp[(1) - (3)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2289,7 +2289,7 @@ yyreduce:
 #line 457 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_init_method((yyvsp[(2) - (3)].meth), get((yyvsp[(3) - (3)].plist)), (yyvsp[(1) - (3)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2331,7 +2331,7 @@ yyreduce:
 #line 497 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (2)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (2)].str));
                  set((yyval.sel), _gmx_sel_init_keyword((yyvsp[(2) - (2)].meth), SelectionParserValueListPointer(), (yyvsp[(1) - (2)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2343,7 +2343,7 @@ yyreduce:
 #line 505 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_init_method((yyvsp[(2) - (3)].meth), get((yyvsp[(3) - (3)].plist)), (yyvsp[(1) - (3)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2436,7 +2436,7 @@ yyreduce:
 #line 570 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard((yyvsp[(1) - (2)].str));
+                 scoped_guard_sfree posmodGuard((yyvsp[(1) - (2)].str));
                  set((yyval.sel), _gmx_sel_init_keyword((yyvsp[(2) - (2)].meth), SelectionParserValueListPointer(), (yyvsp[(1) - (2)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2475,7 +2475,7 @@ yyreduce:
 #line 608 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree keywordGuard((yyvsp[(1) - (3)].str));
+                 scoped_guard_sfree keywordGuard((yyvsp[(1) - (3)].str));
                  set((yyval.sel), _gmx_sel_init_position(get((yyvsp[(3) - (3)].sel)), (yyvsp[(1) - (3)].str), scanner));
                  CHECK_SEL((yyval.sel));
                  END_ACTION;
@@ -2551,7 +2551,7 @@ yyreduce:
 #line 675 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard((yyvsp[(1) - (2)].str));
+                 scoped_guard_sfree nameGuard((yyvsp[(1) - (2)].str));
                  set((yyval.param), SelectionParserParameter::create((yyvsp[(1) - (2)].str), get((yyvsp[(2) - (2)].vlist))));
                  END_ACTION;
              }
@@ -2720,7 +2720,7 @@ yyreduce:
 #line 783 "parser.y"
     {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree stringGuard((yyvsp[(1) - (1)].str));
+                 scoped_guard_sfree stringGuard((yyvsp[(1) - (1)].str));
                  set((yyval.val), SelectionParserValue::createString((yyvsp[(1) - (1)].str)));
                  END_ACTION;
              }
index c90c5829988782f541a90e8a2d3f341a59ac1ecf..bbd080f8fabf919ca7cba36c93a6c1d913cffa34 100644 (file)
 #include "gmxpre.h"
 }
 %{
-#include "gromacs/utility/scoped_ptr_sfree.h"
+#include "gromacs/utility/scoped_cptr.h"
 
 #include "parser_internal.h"
 
-using gmx::scoped_ptr_sfree;
+using gmx::scoped_guard_sfree;
 using gmx::SelectionParserValue;
 using gmx::SelectionParserValueList;
 using gmx::SelectionParserValueListPointer;
@@ -251,7 +251,7 @@ cmd_plain:   /* empty */
            | string
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($1);
+                 scoped_guard_sfree nameGuard($1);
                  SelectionTreeElementPointer s
                         = _gmx_sel_init_group_by_name($1, scanner);
                  SelectionTreeElementPointer p
@@ -269,28 +269,28 @@ cmd_plain:   /* empty */
            | string selection
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($1);
+                 scoped_guard_sfree nameGuard($1);
                  set($$, _gmx_sel_init_selection($1, get($2), scanner));
                  END_ACTION;
              }
            | IDENTIFIER '=' sel_expr
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($1);
+                 scoped_guard_sfree nameGuard($1);
                  set($$, _gmx_sel_assign_variable($1, get($3), scanner));
                  END_ACTION;
              }
            | IDENTIFIER '=' num_expr
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($1);
+                 scoped_guard_sfree nameGuard($1);
                  set($$, _gmx_sel_assign_variable($1, get($3), scanner));
                  END_ACTION;
              }
            | IDENTIFIER '=' pos_expr
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($1);
+                 scoped_guard_sfree nameGuard($1);
                  set($$, _gmx_sel_assign_variable($1, get($3), scanner));
                  END_ACTION;
              }
@@ -382,7 +382,7 @@ sel_expr:    NOT sel_expr
 sel_expr:    num_expr CMP_OP num_expr
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree opGuard($2);
+                 scoped_guard_sfree opGuard($2);
                  set($$, _gmx_sel_init_comparison(get($1), get($3), $2, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -393,7 +393,7 @@ sel_expr:    num_expr CMP_OP num_expr
 sel_expr:    GROUP string
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($2);
+                 scoped_guard_sfree nameGuard($2);
                  set($$, _gmx_sel_init_group_by_name($2, scanner));
                  END_ACTION;
              }
@@ -421,7 +421,7 @@ str_match_type:
 sel_expr:    pos_mod KEYWORD_GROUP
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_keyword($2, SelectionParserValueListPointer(), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -429,7 +429,7 @@ sel_expr:    pos_mod KEYWORD_GROUP
            | pos_mod KEYWORD_STR basic_value_list
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_keyword_strmatch($2, gmx::eStringMatchType_Auto, get($3), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -437,7 +437,7 @@ sel_expr:    pos_mod KEYWORD_GROUP
            | pos_mod KEYWORD_STR str_match_type basic_value_list
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_keyword_strmatch($2, $3, get($4), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -445,7 +445,7 @@ sel_expr:    pos_mod KEYWORD_GROUP
            | pos_mod KEYWORD_NUMERIC basic_value_list
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_keyword($2, get($3), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -456,7 +456,7 @@ sel_expr:    pos_mod KEYWORD_GROUP
 sel_expr:    pos_mod METHOD_GROUP method_params
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_method($2, get($3), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -496,7 +496,7 @@ num_expr:    TOK_INT
 num_expr:    pos_mod KEYWORD_NUMERIC    %prec NUM_REDUCT
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_keyword($2, SelectionParserValueListPointer(), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -504,7 +504,7 @@ num_expr:    pos_mod KEYWORD_NUMERIC    %prec NUM_REDUCT
            | pos_mod METHOD_NUMERIC method_params
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_method($2, get($3), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -569,7 +569,7 @@ str_expr:    string
            | pos_mod KEYWORD_STR
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree posmodGuard($1);
+                 scoped_guard_sfree posmodGuard($1);
                  set($$, _gmx_sel_init_keyword($2, SelectionParserValueListPointer(), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -607,7 +607,7 @@ pos_expr:    METHOD_POS method_params
 pos_expr:    KEYWORD_POS OF sel_expr    %prec PARAM_REDUCT
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree keywordGuard($1);
+                 scoped_guard_sfree keywordGuard($1);
                  set($$, _gmx_sel_init_position(get($3), $1, scanner));
                  CHECK_SEL($$);
                  END_ACTION;
@@ -674,7 +674,7 @@ method_param:
              PARAM value_list
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree nameGuard($1);
+                 scoped_guard_sfree nameGuard($1);
                  set($$, SelectionParserParameter::create($1, get($2)));
                  END_ACTION;
              }
@@ -782,7 +782,7 @@ basic_value_item:
            | string              %prec PARAM_REDUCT
              {
                  BEGIN_ACTION;
-                 scoped_ptr_sfree stringGuard($1);
+                 scoped_guard_sfree stringGuard($1);
                  set($$, SelectionParserValue::createString($1));
                  END_ACTION;
              }
index 6fec3377ab50d3c6af96232aa1c61ce0c1e13917..3e5f2543d813187a171f2b91daaa666dbfd03765 100644 (file)
@@ -71,7 +71,7 @@
 #include "gromacs/trajectoryanalysis/analysissettings.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/futil.h"
-#include "gromacs/utility/scoped_ptr_sfree.h"
+#include "gromacs/utility/scoped_cptr.h"
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/utility/stringutil.h"
 
@@ -942,7 +942,7 @@ Sasa::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
         }
         sfree(area);
     }
-    scoped_ptr_sfree dotsGuard(surfacedots);
+    scoped_guard_sfree dotsGuard(surfacedots);
     if (retval != 0)
     {
         GMX_THROW(InternalError("nsc_dclm_pbc failed"));
index 909c70d6af4716a8839fcb7a5055daecc4b4883f..443c4a129c7934aa0668eca5b4bfdfb68a350541 100644 (file)
@@ -70,7 +70,7 @@
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/scoped_ptr_sfree.h"
+#include "gromacs/utility/scoped_cptr.h"
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/utility/stringutil.h"
 
@@ -652,11 +652,11 @@ Select::writeOutput()
     {
         GMX_RELEASE_ASSERT(top_->hasTopology(),
                            "Topology should have been loaded or an error given earlier");
-        t_atoms          atoms;
+        t_atoms            atoms;
         atoms = top_->topology()->atoms;
-        t_pdbinfo       *pdbinfo;
+        t_pdbinfo         *pdbinfo;
         snew(pdbinfo, atoms.nr);
-        scoped_ptr_sfree pdbinfoGuard(pdbinfo);
+        scoped_guard_sfree pdbinfoGuard(pdbinfo);
         if (atoms.pdbinfo != NULL)
         {
             std::memcpy(pdbinfo, atoms.pdbinfo, atoms.nr*sizeof(*pdbinfo));
similarity index 70%
rename from src/gromacs/utility/scoped_ptr_sfree.h
rename to src/gromacs/utility/scoped_cptr.h
index 7078a80aebfd6b9958df7838bac473d002d5baa2..f4b9ada399c4ec5ed2650597fdaf1e9439b76dce 100644 (file)
@@ -34,7 +34,7 @@
  */
 /*! \libinternal \file
  * \brief
- * Declares gmx::scoped_ptr_sfree.
+ * Declares gmx::scoped_cptr and gmx::scoped_guard_sfree.
  *
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \inlibraryapi
 #ifndef GMX_UTILITY_SCOPED_PTR_SFREE_H
 #define GMX_UTILITY_SCOPED_PTR_SFREE_H
 
+#include "config.h"
+
 #include "gromacs/utility/common.h"
 #include "gromacs/utility/smalloc.h"
 
 namespace gmx
 {
 
+//! sfree wrapper to be used as scoped_cptr deleter
+template <class T>
+inline void sfree_wrapper(T *p)
+{
+    sfree(p);
+}
+
 /*! \libinternal \brief
- * Stripped-down version of scoped_ptr that uses sfree().
+ * Stripped-down version of scoped_ptr that uses sfree() or custom deleter.
  *
- * Currently only implements constructor from a pointer value and destructor;
- * other operations can be added if they become necessary.
+ * Currently only implements some operations; other operations can be added
+ * if they become necessary.
  *
- * This class provides a very basic guard/smart pointer for C pointers.
- * Currently, boost::shared_ptr is used in a few locations that require more
- * flexibility, but is not suitable for all cases either.  A scoped_ptr with
- * deleter support would be a general enough implementation for all uses.
- * C++11 unique_ptr has this, but for non-C++11 support we need something else.
+ * This class provides a basic guard/smart pointer for C pointers.
  *
  * Methods in this class do not throw.
  *
  * \inlibraryapi
  * \ingroup module_utility
  */
-class scoped_ptr_sfree
+template <class T, void D(T *) = sfree_wrapper>
+class scoped_cptr
 {
     public:
         /*! \brief
@@ -74,16 +80,26 @@ class scoped_ptr_sfree
          *
          * \param[in] ptr  Pointer to use for initialization.
          */
-        explicit scoped_ptr_sfree(void *ptr) : ptr_(ptr) {}
+        explicit scoped_cptr(T *ptr) : ptr_(ptr) {}
         //! Frees the pointer passed to the constructor.
-        ~scoped_ptr_sfree() { sfree(ptr_); }
+        ~scoped_cptr() { D(ptr_); }
+        //! Returns the stored pointer.
+        T * get() const { return ptr_; }
+        //! Check for non-null pointer in boolean context.
+#ifdef GMX_CXX11
+        explicit
+#endif
+        operator bool () const { return ptr_ != 0; }
 
     private:
-        void                   *ptr_;
+                           *ptr_;
 
-        GMX_DISALLOW_COPY_AND_ASSIGN(scoped_ptr_sfree);
+        GMX_DISALLOW_COPY_AND_ASSIGN(scoped_cptr);
 };
 
+//! Simple guard which calls sfree. See scoped_cptr for details.
+typedef scoped_cptr<void> scoped_guard_sfree;
+
 }      // namespace gmx
 
 #endif