diff --git a/include/deque b/include/deque index b0b778a5..c6fbd512 100644 --- a/include/deque +++ b/include/deque @@ -1196,6 +1196,9 @@ public: typedef _Tp value_type; typedef _Allocator allocator_type; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + typedef __deque_base __base; typedef typename __base::__alloc_traits __alloc_traits; diff --git a/include/forward_list b/include/forward_list index 8a87fc5e..adbc32cf 100644 --- a/include/forward_list +++ b/include/forward_list @@ -537,6 +537,9 @@ public: typedef _Tp value_type; typedef _Alloc allocator_type; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + typedef value_type& reference; typedef const value_type& const_reference; typedef typename allocator_traits::pointer pointer; diff --git a/include/map b/include/map index 561c3ddc..adfb4cdb 100644 --- a/include/map +++ b/include/map @@ -840,6 +840,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { @@ -1696,6 +1699,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { diff --git a/include/set b/include/set index 9d64a521..ac69e085 100644 --- a/include/set +++ b/include/set @@ -409,6 +409,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + private: typedef __tree __base; typedef allocator_traits __alloc_traits; @@ -819,6 +822,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + private: typedef __tree __base; typedef allocator_traits __alloc_traits; diff --git a/test/std/containers/associative/map/allocator_mismatch.fail.cpp b/test/std/containers/associative/map/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..f5da1453 --- /dev/null +++ b/test/std/containers/associative/map/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::map, std::allocator > m; +} diff --git a/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp b/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..18823212 --- /dev/null +++ b/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::multimap, std::allocator > m; +} diff --git a/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp b/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..b2b30d6f --- /dev/null +++ b/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::multiset, std::allocator > ms; +} diff --git a/test/std/containers/associative/set/allocator_mismatch.fail.cpp b/test/std/containers/associative/set/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..6905d934 --- /dev/null +++ b/test/std/containers/associative/set/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::set, std::allocator > s; +} diff --git a/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp b/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..9223c1ec --- /dev/null +++ b/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::deque > d; +} diff --git a/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp b/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..b53075d0 --- /dev/null +++ b/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::forward_list > fl; +} diff --git a/test/std/containers/sequences/list/allocator_mismatch.fail.cpp b/test/std/containers/sequences/list/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..3490d106 --- /dev/null +++ b/test/std/containers/sequences/list/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::list > l; +} diff --git a/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp b/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..65fdb63e --- /dev/null +++ b/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::vector > v; +} diff --git a/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..39fcb11a --- /dev/null +++ b/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_map, std::less, std::allocator > m; +} diff --git a/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..3c740950 --- /dev/null +++ b/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_multimap, std::less, std::allocator > m; +} diff --git a/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..5836cb36 --- /dev/null +++ b/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_multiset, std::less, std::allocator > v; +} diff --git a/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..b87c9a24 --- /dev/null +++ b/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_set, std::less, std::allocator > v; +} diff --git a/test/std/strings/basic.string/allocator_mismatch.fail.cpp b/test/std/strings/basic.string/allocator_mismatch.fail.cpp new file mode 100644 index 00000000..644137ec --- /dev/null +++ b/test/std/strings/basic.string/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::basic_string, std::allocator > s; +}