This fixes symbol::get_name(), which returned an empty string instead of
"symbol" followed by the serial number if the symbol's name wasn't
specified in the constructor.
Thanks to Warren Weckesser for reporting this bug.
(cherry picked from commit
f5abf61d2cb1a1d1809d270a24fa098575b172c4)
+std::string symbol::get_name() const
+{
+ if (name.empty()) {
+ std::ostringstream s;
+ s << "symbol" << serial;
+ name = s.str();
+ }
+ return name;
+}
+
+// protected
+
void symbol::do_print(const print_context & c, unsigned level) const
{
void symbol::do_print(const print_context & c, unsigned level) const
{
- if (!name.empty())
- c.s << name;
- else
- c.s << "symbol" << serial;
}
void symbol::do_print_latex(const print_latex & c, unsigned level) const
}
void symbol::do_print_latex(const print_latex & c, unsigned level) const
// non-virtual functions in this class
public:
void set_name(const std::string & n) { name = n; }
// non-virtual functions in this class
public:
void set_name(const std::string & n) { name = n; }
- std::string get_name() const { return name; }
+ std::string get_name() const;
virtual unsigned get_domain() const { return domain::complex; }
protected:
void do_print(const print_context & c, unsigned level) const;
virtual unsigned get_domain() const { return domain::complex; }
protected:
void do_print(const print_context & c, unsigned level) const;
protected:
unsigned serial; ///< unique serial number for comparison
protected:
unsigned serial; ///< unique serial number for comparison
- std::string name; ///< printname of this symbol
+ mutable std::string name; ///< printname of this symbol
std::string TeX_name; ///< LaTeX name of this symbol
private:
static unsigned next_serial;
std::string TeX_name; ///< LaTeX name of this symbol
private:
static unsigned next_serial;
GINAC_DECLARE_UNARCHIVER(realsymbol);
GINAC_DECLARE_UNARCHIVER(realsymbol);
-/** Specialization of symbol to real domain */
+/** Specialization of symbol to real positive domain */
class possymbol : public realsymbol
{
public:
class possymbol : public realsymbol
{
public: