<p>I would like to throw an exception when my C++ methods encounter something weird and can't recover. Is it OK to throw a <code>std::string</code> pointer?</p>

<p>Here's what I was looking forward to doing:</p>

<pre><code>void Foo::Bar() {
    if(!QueryPerformanceTimer(&amp;m_baz)) {
        throw new std::string("it's the end of the world!");
    }
}

void Foo::Caller() {
    try {
        this-&gt;Bar(); // should throw
    }
    catch(std::string *caught) { // not quite sure the syntax is OK here...
        std::cout &lt;&lt; "Got " &lt;&lt; caught &lt;&lt; std::endl;
    }
}
</code></pre>

It works, but I wouldn't do it if I were you.  You don't seem to be deleting that heap data when you're done, which means that you've created a memory leak.  The C++ compiler takes care of ensuring that exception data is kept alive even as the stack is popped, so don't feel that you need to use the heap.
Incidentally, throwing a
```
std::string
```
isn't the best approach to begin with.  You'll have a lot more flexibility down the road if you use a simple wrapper object.  It may just encapsulate a
```
string
```
for now, but maybe in future you will want to include other information, like some data which caused the exception or maybe a line number (very common, that).  You don't want to change all of your exception handling in every spot in your code-base, so take the high road now and don't throw raw objects.