Pay attention to the following code:
throw my_exception() << "The error " << error_code << " happened because of " << reasons;
The helper code will look something like this:
class my_exception
{
   public:
      template <typename T>
      my_exception & operator << (const T & value)
      {
         
         return *this;
      }
      
};
Is there any reason that would make it so throwdangerous or simply ineffective compared to the alternative below?
std::stringstream s;
s << "The error " << error_code << " happened because of " << reasons;
throw my_exception(s.str());
source
share