forked from boostorg/container
Adding Constructor Template Auto Deduction guides.
This commit is contained in:
1 parent
b3eee90a81
commit
72195ae288
20 files changed
+455
No files matched your search
@@ -282,6 +282,20 @@ bool do_test()
|
||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return 1;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//Check Constructor Template Auto Deduction
|
||||
{
|
||||
auto gold = MyStdDeque{ 1, 2, 3 };
|
||||
auto test = deque(gold.begin(), gold.end());
|
||||
if(!test::CheckEqualContainers(gold, test)) return false;
|
||||
}
|
||||
{
|
||||
auto gold = MyStdDeque{ 1, 2, 3 };
|
||||
auto test = deque(gold.begin(), gold.end(), new_allocator<int>());
|
||||
if(!test::CheckEqualContainers(gold, test)) return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::cout << std::endl << "Test OK!" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -248,6 +248,36 @@ bool flat_tree_ordered_insertion_test()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool constructor_template_auto_deduction_test()
|
||||
{
|
||||
#if __cplusplus >= 201703L
|
||||
using namespace boost::container;
|
||||
const std::size_t NumElements = 100;
|
||||
//Ordered insertion map
|
||||
{
|
||||
std::map<int, int> int_map;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_map.insert(std::map<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
//Construction insertion
|
||||
auto fmap = flat_map(ordered_unique_range, int_map.begin(), int_map.end());
|
||||
if(!CheckEqualContainers(int_map, fmap))
|
||||
return false;
|
||||
|
||||
std::multimap<int, int> int_mmap;
|
||||
for(std::size_t i = 0; i != NumElements; ++i){
|
||||
int_mmap.insert(std::multimap<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
|
||||
}
|
||||
//Construction insertion
|
||||
auto fmmap = flat_multimap(ordered_range, int_mmap.begin(), int_mmap.end());
|
||||
if(!CheckEqualContainers(int_mmap, fmmap))
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template< class RandomIt >
|
||||
void random_shuffle( RandomIt first, RandomIt last )
|
||||
{
|
||||
@@ -517,6 +547,13 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction test
|
||||
////////////////////////////////////
|
||||
if(!constructor_template_auto_deduction_test()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
// Extract/Adopt test
|
||||
////////////////////////////////////
|
||||
|
||||
@@ -695,6 +695,30 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::set({ 1, 2, 3 });
|
||||
auto test = boost::container::flat_set(gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
test = boost::container::flat_set(ordered_unique_range, gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
auto gold = std::multiset({ 1, 2, 3 });
|
||||
auto test = boost::container::flat_multiset(gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
test = boost::container::flat_multiset(ordered_range, gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -211,6 +211,44 @@ int main ()
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction Tests
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::list{ 1, 2, 3 };
|
||||
auto test = boost::container::list(gold.begin(), gold.end());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (test.front() != 1)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 2)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 3)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
}
|
||||
{
|
||||
auto gold = std::list{ 1, 2, 3 };
|
||||
auto test = boost::container::list(gold.begin(), gold.end(), new_allocator<int>());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (test.front() != 1)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 2)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 3)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -426,6 +426,24 @@ int main ()
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::map<int, int>({ {1,1}, {2,2}, {3,3} } );
|
||||
auto test = boost::container::map(gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
auto gold = std::multimap<int, int>({ {1,1}, {2,2}, {3,3} } );
|
||||
auto test = boost::container::multimap(gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////
|
||||
// Node extraction/insertion testing functions
|
||||
////////////////////////////////////
|
||||
|
||||
@@ -455,6 +455,30 @@ int main ()
|
||||
if(!node_type_test())
|
||||
return 1;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::set({ 1, 2, 3 });
|
||||
auto test = boost::container::set(gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
test = boost::container::set(ordered_unique_range, gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
auto gold = std::multiset({ 1, 2, 3 });
|
||||
auto test = boost::container::multiset(gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
test = boost::container::multiset(ordered_range, gold.begin(), gold.end());
|
||||
if (test.size() != 3)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -251,6 +251,45 @@ int main ()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction Tests
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::list{ 1, 2, 3 };
|
||||
auto test = boost::container::slist(gold.begin(), gold.end());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (test.front() != 1)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 2)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 3)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
}
|
||||
{
|
||||
auto gold = std::list{ 1, 2, 3 };
|
||||
auto test = boost::container::slist(gold.begin(), gold.end(), new_allocator<int>());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (test.front() != 1)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 2)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
if (test.front() != 3)
|
||||
return 1;
|
||||
test.pop_front();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
@@ -193,6 +193,22 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction testing
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::vector{ 1, 2, 3 };
|
||||
auto test = boost::container::stable_vector(gold.begin(), gold.end());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (!(test[0] == 1 && test[1] == 2 && test[2] == 3)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -478,6 +478,18 @@ int string_test()
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//Chect Constructor Template Auto Deduction
|
||||
{
|
||||
auto gold = StdString(string_literals<CharType>::String());
|
||||
auto test = basic_string(gold.begin(), gold.end());
|
||||
if(!StringEqual()(gold, test)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//When done, delete vector
|
||||
delete boostStringVect;
|
||||
delete stdStringVect;
|
||||
|
||||
@@ -250,5 +250,31 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
////////////////////////////////////
|
||||
// Constructor Template Auto Deduction testing
|
||||
////////////////////////////////////
|
||||
{
|
||||
auto gold = std::vector{ 1, 2, 3 };
|
||||
auto test = boost::container::vector(gold.begin(), gold.end());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (!(test[0] == 1 && test[1] == 2 && test[2] == 3)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
auto gold = std::vector{ 1, 2, 3 };
|
||||
auto test = boost::container::vector(gold.begin(), gold.end(), boost::container::new_allocator<int>());
|
||||
if (test.size() != 3) {
|
||||
return 1;
|
||||
}
|
||||
if (!(test[0] == 1 && test[1] == 2 && test[2] == 3)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user