aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-07-24 14:03:25 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-07-24 14:03:25 +0100
commit4f3c75ba3a62d6f3794afd10d191807a68d7ba3b (patch)
tree8cab9715292c43bb5134cb78f788dd258ee8db13
parent7a4be380498046d9b0f88d32ff5a3189c913cc75 (diff)
downloadgcc-4f3c75ba3a62d6f3794afd10d191807a68d7ba3b.zip
gcc-4f3c75ba3a62d6f3794afd10d191807a68d7ba3b.tar.gz
gcc-4f3c75ba3a62d6f3794afd10d191807a68d7ba3b.tar.bz2
Reorder conditions in uses-allocator construction helper
The erased_type condition is only true for code using the Library Fundamentals TS, so assume it's less common and only check it after checking for convertibility. This does mean for types using erased_type the more expensive convertibility check is done first, but such types are rare. * include/bits/uses_allocator.h (__is_erased_or_convertible): Reorder conditions. Add comments. * testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error line. * testsuite/20_util/uses_allocator/cons_neg.cc: Likewise. * testsuite/20_util/scoped_allocator/69293_neg.cc: Likewise. From-SVN: r262945
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/bits/uses_allocator.h6
-rw-r--r--libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc2
5 files changed, 18 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ede29a4..dc8dfda 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
2018-07-24 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/uses_allocator.h (__is_erased_or_convertible): Reorder
+ conditions. Add comments.
+ * testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error line.
+ * testsuite/20_util/uses_allocator/cons_neg.cc: Likewise.
+ * testsuite/20_util/scoped_allocator/69293_neg.cc: Likewise.
+
+ * include/bits/uses_allocator.h (__is_erased_or_convertible): Remove.
+ (__uses_allocator_helper): Check conditions directly instead of
+ using __is_erased_or_convertible.
+
* include/experimental/memory_resource: Adjust comments and
whitespace.
(__resource_adaptor_imp): Add second template parameter for type of
diff --git a/libstdc++-v3/include/bits/uses_allocator.h b/libstdc++-v3/include/bits/uses_allocator.h
index 820a2a5..3ef2830 100644
--- a/libstdc++-v3/include/bits/uses_allocator.h
+++ b/libstdc++-v3/include/bits/uses_allocator.h
@@ -36,11 +36,15 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ // This is used for std::experimental::erased_type from Library Fundamentals.
struct __erased_type { };
+ // This also supports the "type-erased allocator" protocol from the
+ // Library Fundamentals TS, where allocator_type is erased_type.
+ // The second condition will always be false for types not using the TS.
template<typename _Alloc, typename _Tp>
using __is_erased_or_convertible
- = __or_<is_same<_Tp, __erased_type>, is_convertible<_Alloc, _Tp>>;
+ = __or_<is_convertible<_Alloc, _Tp>, is_same<_Tp, __erased_type>>;
/// [allocator.tag]
struct allocator_arg_t { explicit allocator_arg_t() = default; };
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc
index 621ff47..168079f 100644
--- a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc
@@ -46,5 +46,5 @@ test01()
scoped_alloc sa;
auto p = sa.allocate(1);
sa.construct(p); // this is required to be ill-formed
- // { dg-error "static assertion failed" "" { target *-*-* } 90 }
+ // { dg-error "static assertion failed" "" { target *-*-* } 94 }
}
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc
index 348ed41..eaf4324 100644
--- a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc
@@ -44,5 +44,5 @@ test01()
{
alloc_type a;
std::tuple<X> t(std::allocator_arg, a); // this is required to be ill-formed
- // { dg-error "static assertion failed" "" { target *-*-* } 90 }
+ // { dg-error "static assertion failed" "" { target *-*-* } 94 }
}
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
index 8894e38..bb8c38d 100644
--- a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
@@ -43,4 +43,4 @@ void test01()
tuple<Type> t(allocator_arg, a, 1);
}
-// { dg-error "static assertion failed" "" { target *-*-* } 90 }
+// { dg-error "static assertion failed" "" { target *-*-* } 94 }