lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 43f4ba6 2/2: Make glossed_string::operator=()


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 43f4ba6 2/2: Make glossed_string::operator=() modify gloss as well as string
Date: Sun, 24 Feb 2019 16:11:04 -0500 (EST)

branch: master
commit 43f4ba6afae10a5f554348e540c2f4f659211513
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Make glossed_string::operator=() modify gloss as well as string
    
    Curiously, glossed_string::operator=(std::string const&) modified the
    string datum but retained the gloss. Effect:
      glossed_string z("Whatever", "Must not be empty");
      z = "";
      // z is now {"", "Must not be empty"}: an empty string whose gloss
      // states that it must not be empty.
    Now this operator=() resets the gloss, so that the example above instead
    results in {"",""}. This behavior is more useful and less astonishing.
---
 product_data.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/product_data.cpp b/product_data.cpp
index f047c39..69fc8d9 100644
--- a/product_data.cpp
+++ b/product_data.cpp
@@ -98,6 +98,7 @@ glossed_string::glossed_string
 glossed_string& glossed_string::operator=(std::string const& s)
 {
     datum_ = s;
+    gloss_ = "";
     return *this;
 }
 



reply via email to

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