+2013-03-04 Miguel Angel Arruga Vivas <rosen644835@gmail.com> (tiny change)
+
+ Add 'autosprintf::operator='. Needed because destructor
+ is not trivial.
+ Reported at <https://savannah.gnu.org/bugs/?33102>
+ * autosprintf.in.h (autosprintf::operator=): New function.
+ Thanks to Daiki Ueno for pointing a better copy-and-swap
+ idiom use.
+ * autosprintf.cc (autosprintf::operator=): Likewise.
+
2013-01-17 Daiki Ueno <ueno@gnu.org>
Fix link errors related to C99-style extern inline.
/* Class autosprintf - formatted output to an ostream.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2013 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify
#include <string.h>
#include "lib-asprintf.h"
+/* std::swap() is in <utility> since C++11. */
+#if __cplusplus >= 201103L
+# include <utility>
+#else
+# include <algorithm>
+#fi
+
namespace gnu
{
str = (src.str != NULL ? strdup (src.str) : NULL);
}
+ /* Copy constructor. Necessary because the destructor is nontrivial. */
+ autosprintf& autosprintf::operator = (autosprintf copy)
+ {
+ std::swap (tmp.str, this->str);
+ return *this;
+ }
+
/* Destructor: frees the temporarily allocated string. */
autosprintf::~autosprintf ()
{
/* Class autosprintf - formatted output to an ostream.
- Copyright (C) 2002, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2012, 2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
__attribute__ ((__format__ (__printf__, 2, 3)));
/* Copy constructor. */
autosprintf (const autosprintf& src);
+ autosprintf& operator = (autosprintf copy);
/* Destructor: frees the temporarily allocated string. */
~autosprintf ();
/* Conversion to string. */