boostorg/variant — pull request #4 by ralphtandetzky (2014-04-11 08:08:51+00:00)
Title: Bugfix: forced_return<T>() did lead to compile-time errors for move-only...

... types.

When implementing a visitor that returns an std::unique_ptr the code compiled in Visual Studio 2010 and 2012, but not with GCC 4.8.2 since the copy constructor is required in the line

return *static_cast< basic_type* >(dummy);

This line is not compiled under Visual Studio since it is checked whether the macro BOOST_MSVC is defined. It should be ok to throw here, since the code is not called at run-time anyways.

Throwing should work in most circumstances, but I'm not sure what to do in the case where RTTI is disabled and hence exceptions are not allowed. Possibly a recursive call to forced_return() is an alternative here. I don't fully comprehend what forced_return is needed for. If someone's reading this, please check if

return forced_return();

would not be a better line to put here.