title: In multiset , the code does not enter into compare function and throws error
body: <p>I have used breakpoints to check if my compare function is being called while inserting element into Multi-set  but it never reaches the  breakpoint.</p>
  
  <p>The error <code>Unhandled exception at 0x003c5a71 in Regular_Calibration_d.exe: 0xC0000005: Access violation reading location 0x00000014.</code></p>
  
  <p>I pasting the code below. Please let me know where I am doing wrong .
  Couple of  important thing  in which I have a doubt .</p>
  
  <ul>
  <li><p>1) I am manipulating  sms.message  before actually inserting it in
     multi-set   so do you guys think that I am doing something wrong
     there  which creates the probelem? </p></li>
  <li><p>2) If I think for a time being
        that something is wrong with string manipulation but then why it
        doesnt hit the comapre function which compare time .</p></li>
  </ul>
  
  <p>Below are my code.</p>
  
  <p>structure of SMS</p>
  
  <pre><code>struct SMS
  {
    SMS(const SMSType::Enum e, const QString&amp; s);
    QDateTime          time;
    SMSType::Enum      smsType;
    QString            message;
  };
  </code></pre>
  
  <p>//construtcor of message </p>
  
  <pre><code>SMS::SMS( const SMSType::Enum e, const QString&amp; s )
  : smsType( e ), message( s )
  {
     time = QDateTime::currentDateTime();
  
  }
  </code></pre>
  
  <p>//compare function</p>
  
  <pre><code>bool SMS_list::LessSMSTime::operator ()( const SMS&amp; left,
                       const SMS&amp; right ) const
  {
  
    QDate date_left  = left.time.date();
    QDate date_right = right.time.date();
  
    if( date_left.year() &lt; date_right.year() )
      return true;
    else if( date_left.year() &gt; date_right.year() )
      return false;
  
    if( date_left.month() &lt; date_right.month() )
      return true;
    else if( date_left.month() &gt; date_right.month() )
      return false;
  
    if( date_left.day() &lt; date_right.day() )
      return true;
    else if( date_left.day() &gt; date_right.day() )
      return false;
  
    QTime time_left  = left.time.time(); 
    QTime time_right = right.time.time(); 
  
    if( time_left.hour() &lt; time_right.hour() )
           return true;
      else if( time_left .hour() &gt; time_right.hour() )
           return false;
  
   if( time_left.minute() &lt; time_right.minute() )
           return true;
      else if( time_left.minute() &gt; time_right.minute() )
           return false;
  
    if( time_left.second() &lt; time_right.second() )
            return true;
       else if( time_left.second() &gt; time_right.second() )
            return false;
  
    if( time_left.msec() &lt; time_right.msec () )
            return true;
  
    return false;
  }
  </code></pre>
  
  <p>//declaration of multiset</p>
  
  <pre><code>std::multiset&lt;SMS, LessSMSTime&gt; SMSSet;
  </code></pre>
  
  <p>// in some function  </p>
  
  <pre><code>SMSSet.insert( sms ) ;
  </code></pre>
  
  <p>// string manipulation</p>
  
  <pre><code>void SMSInterface::output( const SMSType::Enum type, QString str_qt ) const
  {
  
   // convert QString to std::String
   std::string str = str_qt.toStdString();
   QMutex mutex;
   mutex.lock();
  
   if( str[ str.length() - 1 ] == '\n' )
   {
    str = std::string( str.cbegin(),   str.cbegin() + str.length() - 1 );
   }
  
   //convert std::string to QString
   QString str_to_qt = QString::fromStdString ( str );
  // QString str_to_qt = QString::fromUtf8 ( str.c_str() );
  
      SMS sms( type, str_to_qt );
      sms_list_-&gt;add_sms( message ); // inside this function multi-set insertion is called
  bla bala 
  
  
   mutex.unlock();
  }
  </code></pre>