diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-01-25 01:15:41 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-01-25 01:15:41 +0000 |
| commit | a7b224140784fb4694109e9a6d62097d246bdcd1 (patch) | |
| tree | 8270aeb631edc6a88bc947927879aa2f00ca05da /libcxx/test | |
| parent | 86b84c25d10860bbb0257630d5ecaeb061d31ca9 (diff) | |
| download | bcm5719-llvm-a7b224140784fb4694109e9a6d62097d246bdcd1.tar.gz bcm5719-llvm-a7b224140784fb4694109e9a6d62097d246bdcd1.zip | |
Eliminate the C++0x-only is_convertible testing function that accepts
a cv-qualifier rvalue reference to the type, e.g.,
template <class _Tp> char __test(const volatile typename remove_reference<_Tp>::type&&);
The use of this function signature rather than the more
straightforward one used in C++98/03 mode, e.g.,
template <class _Tp> char __test(_Tp);
is broken in two ways:
1) An rvalue reference cannot bind to lvalues, so is_convertible<X&,
X&>::value would be false. This breaks two of the unique_ptr tests
on Clang and GCC >= 4.5. Prior GCC's seem to have allowed rvalue
references to bind to lvalues, allowing this bug to slip in.
2) By adding cv-qualifiers to the type we're converting to, we get
some incorrect "true" results for, e.g., is_convertible<const X&, X&>::value.
llvm-svn: 124166
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/utilities/meta/meta.rel/is_convertible.pass.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libcxx/test/utilities/meta/meta.rel/is_convertible.pass.cpp b/libcxx/test/utilities/meta/meta.rel/is_convertible.pass.cpp index 1c63f9fb0b9..8d05668992e 100644 --- a/libcxx/test/utilities/meta/meta.rel/is_convertible.pass.cpp +++ b/libcxx/test/utilities/meta/meta.rel/is_convertible.pass.cpp @@ -16,6 +16,10 @@ typedef void Function(); typedef char Array[1]; +class NonCopyable { + NonCopyable(NonCopyable&); +}; + int main() { { @@ -366,4 +370,15 @@ int main() static_assert((!std::is_convertible<const char*, char*>::value), ""); static_assert(( std::is_convertible<const char*, const char*>::value), ""); } + { + static_assert((std::is_convertible<NonCopyable&, NonCopyable&>::value), ""); + static_assert((std::is_convertible<NonCopyable&, const NonCopyable&>::value), ""); + static_assert((std::is_convertible<NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<NonCopyable&, volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<const NonCopyable&, const NonCopyable&>::value), ""); + static_assert((std::is_convertible<const NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<volatile NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((std::is_convertible<const volatile NonCopyable&, const volatile NonCopyable&>::value), ""); + static_assert((!std::is_convertible<const NonCopyable&, NonCopyable&>::value), ""); + } } |

