mirror of
https://github.com/boostorg/intrusive.git
synced 2025-05-09 23:03:56 +00:00
Add workaround for MSVC 14-0 bad code generation in slist_test
This commit is contained in:
parent
f2afafa6bb
commit
cfc6b4e510
@ -91,25 +91,15 @@ BOOST_INTRUSIVE_FORCEINLINE std::ptrdiff_t offset_from_pointer_to_member(const M
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member)
|
||||
{
|
||||
return static_cast<Parent*>
|
||||
(
|
||||
static_cast<void*>
|
||||
(
|
||||
static_cast<char*>(static_cast<void*>(member)) - offset_from_pointer_to_member(ptr_to_member)
|
||||
)
|
||||
);
|
||||
return reinterpret_cast<Parent*>
|
||||
(reinterpret_cast<std::size_t>(member) - static_cast<std::size_t>(offset_from_pointer_to_member(ptr_to_member)));
|
||||
}
|
||||
|
||||
template<class Parent, class Member>
|
||||
BOOST_INTRUSIVE_FORCEINLINE const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
|
||||
{
|
||||
return static_cast<const Parent*>
|
||||
(
|
||||
static_cast<const void*>
|
||||
(
|
||||
static_cast<const char*>(static_cast<const void*>(member)) - offset_from_pointer_to_member(ptr_to_member)
|
||||
)
|
||||
);
|
||||
return reinterpret_cast<const Parent*>
|
||||
( reinterpret_cast<std::size_t>(member) - static_cast<std::size_t>(offset_from_pointer_to_member(ptr_to_member)) );
|
||||
}
|
||||
|
||||
} //namespace detail {
|
||||
|
@ -152,7 +152,7 @@ class linear_slist_algorithms
|
||||
//!
|
||||
//! <b>Throws</b>: Nothing.
|
||||
inline static void init_header(node_ptr this_node) BOOST_NOEXCEPT
|
||||
{ NodeTraits::set_next(this_node, node_ptr ()); }
|
||||
{ NodeTraits::set_next(this_node, node_ptr()); }
|
||||
|
||||
//! <b>Requires</b>: 'p' is the first node of a list.
|
||||
//!
|
||||
|
@ -355,48 +355,15 @@ void test_slist< ListType, ValueContainer >
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
|
||||
{ //splice in the same list
|
||||
list_type testlist1 (values.begin(), values.begin() + 5);
|
||||
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
//nop 1
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, testlist1.before_begin(), ++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
//nop 2
|
||||
testlist1.splice_after (++testlist1.before_begin(), testlist1, testlist1.before_begin(), ++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
//nop 3
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++++testlist1.before_begin());
|
||||
{ int init_values [] = { 2, 1, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++++++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 3, 2, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
testlist1.splice_after (++++++++testlist1.before_begin(), testlist1, testlist1.before_begin(), ++++testlist1.before_begin());
|
||||
{ int init_values [] = { 2, 4, 1, 3, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
}
|
||||
|
||||
{ //Now test swap when testlist2 is empty
|
||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||
list_type testlist2;
|
||||
BOOST_TEST(testlist2.empty());
|
||||
testlist1.swap(testlist2);
|
||||
BOOST_TEST (testlist1.empty());
|
||||
{ int init_values [] = { 1, 2 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||
}
|
||||
}
|
||||
{ //Now test swap when testlist1 is empty
|
||||
list_type testlist2 (values.begin(), values.begin() + 2);
|
||||
list_type testlist1;
|
||||
@ -457,6 +424,42 @@ void test_slist< ListType, ValueContainer >
|
||||
{ int init_values [] = { 1 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
}
|
||||
|
||||
{ //splice in the same list
|
||||
list_type testlist1 (values.begin(), values.begin() + 5);
|
||||
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
//nop 1
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, testlist1.before_begin(), ++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
//nop 2
|
||||
testlist1.splice_after (++testlist1.before_begin(), testlist1, testlist1.before_begin(), ++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
//nop 3
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
#if !defined(BOOST_MSVC) || (BOOST_MSVC != 1900) //Visual 2015 has problems generating this test code
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++++testlist1.before_begin());
|
||||
{ int init_values [] = { 2, 1, 3, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++++++testlist1.before_begin());
|
||||
{ int init_values [] = { 1, 3, 2, 4, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
|
||||
testlist1.splice_after (++++++++testlist1.before_begin(), testlist1, testlist1.before_begin(), ++++testlist1.before_begin());
|
||||
{ int init_values [] = { 2, 4, 1, 3, 5 };
|
||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
template < typename ListType, typename ValueContainer >
|
||||
@ -683,13 +686,13 @@ int main(int, char* [])
|
||||
{
|
||||
// test (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||
test_main_template<void*, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||
test_main_template<void*, true, true>()();
|
||||
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
||||
test_main_template_bptr< true >()();
|
||||
test_main_template_bptr< false >()();
|
||||
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user