[cfe-dev] noexcept and local variables

Howard Hinnant hhinnant at apple.com
Fri May 27 12:22:55 PDT 2011


On May 27, 2011, at 11:11 AM, Howard Hinnant wrote:

> I've checked in libc++ workarounds for this.

I no longer consider the libc++ implementation to have workarounds for this issue.  The expression-based implementation was incorrect anyway, at least for where and how I was using it.  The noexcept expression in:

template<class T>
class A
{
   T t_;
public:
   void swap(A&  y) noexcept(noexcept(swap(t_, y.t_)));
};

can cause std::swap(T&,T&) to be fully instantiated which causes problems for type T that aren't swappable, even if A<T>::swap is never instantiated.  When for example T was a non-copyable, non-movable, but default constructible type D, then:

  A<D> a;

would fail to compile because of instantiating std::swap(D&, D&).

I've created __is_swappable<T> and __is_nothrow_swappable<T> to put into the noexcepts everywhere I need to.

Howard




More information about the cfe-dev mailing list