title: Check if std::string is a valid uuid using boost
body: <p>I want to check if a given string is a valid UUID using boost. </p>
  
  <p>This is what I have come up with by looking at the documentation on the boost website:</p>
  
  <pre><code>void validate_uuid(const std::string&amp; value)
  {
      try
      {
          boost::uuids::string_generator stringGenerator;
          (void)stringGenerator(value);
      }
  
      catch (const std::exception&amp; ex)
      {
          // ...
      }
  }
  </code></pre>
  
  <p>However, this does not always work. </p>
  
  <p>If I call the function with a string that is too short for a valid UUID, an exception is thrown as expected. But if I call the function with an invalid UUID (e.g. <code>00000000-0000-0000-0000-00000000000K</code>) no exception is thrown. </p>
  
  <p>Please can someone clarify why this is happening.</p>
  
  <p>Also, I've seen the use of boost::lexical_cast to read a string as a UUID as posted <a href="https://stackoverflow.com/a/22036702/820657">here</a>. I'm wondering if I should follow that approach. Any advice appreciated.</p>