mirror of
https://github.com/boostorg/intrusive.git
synced 2025-07-31 04:57:32 +02:00
Add workaround for MSVC 14-0 bad code generation in slist_test
This commit is contained in:
@ -91,25 +91,15 @@ BOOST_INTRUSIVE_FORCEINLINE std::ptrdiff_t offset_from_pointer_to_member(const M
|
|||||||
template<class Parent, class Member>
|
template<class Parent, class Member>
|
||||||
BOOST_INTRUSIVE_FORCEINLINE Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member)
|
BOOST_INTRUSIVE_FORCEINLINE Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member)
|
||||||
{
|
{
|
||||||
return static_cast<Parent*>
|
return reinterpret_cast<Parent*>
|
||||||
(
|
(reinterpret_cast<std::size_t>(member) - static_cast<std::size_t>(offset_from_pointer_to_member(ptr_to_member)));
|
||||||
static_cast<void*>
|
|
||||||
(
|
|
||||||
static_cast<char*>(static_cast<void*>(member)) - offset_from_pointer_to_member(ptr_to_member)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Parent, class Member>
|
template<class Parent, class Member>
|
||||||
BOOST_INTRUSIVE_FORCEINLINE const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
|
BOOST_INTRUSIVE_FORCEINLINE const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
|
||||||
{
|
{
|
||||||
return static_cast<const Parent*>
|
return reinterpret_cast<const Parent*>
|
||||||
(
|
( reinterpret_cast<std::size_t>(member) - static_cast<std::size_t>(offset_from_pointer_to_member(ptr_to_member)) );
|
||||||
static_cast<const void*>
|
|
||||||
(
|
|
||||||
static_cast<const char*>(static_cast<const void*>(member)) - offset_from_pointer_to_member(ptr_to_member)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace detail {
|
} //namespace detail {
|
||||||
|
@ -152,7 +152,7 @@ class linear_slist_algorithms
|
|||||||
//!
|
//!
|
||||||
//! <b>Throws</b>: Nothing.
|
//! <b>Throws</b>: Nothing.
|
||||||
inline static void init_header(node_ptr this_node) BOOST_NOEXCEPT
|
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.
|
//! <b>Requires</b>: 'p' is the first node of a list.
|
||||||
//!
|
//!
|
||||||
|
@ -355,43 +355,10 @@ void test_slist< ListType, ValueContainer >
|
|||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
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
|
{ //Now test swap when testlist2 is empty
|
||||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||||
list_type testlist2;
|
list_type testlist2;
|
||||||
|
BOOST_TEST(testlist2.empty());
|
||||||
testlist1.swap(testlist2);
|
testlist1.swap(testlist2);
|
||||||
BOOST_TEST (testlist1.empty());
|
BOOST_TEST (testlist1.empty());
|
||||||
{ int init_values [] = { 1, 2 };
|
{ int init_values [] = { 1, 2 };
|
||||||
@ -457,6 +424,42 @@ void test_slist< ListType, ValueContainer >
|
|||||||
{ int init_values [] = { 1 };
|
{ int init_values [] = { 1 };
|
||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
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 >
|
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 (plain/smart pointers) x (nonconst/const size) x (void node allocator)
|
||||||
test_main_template<void*, false, true>()();
|
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<void*, true, true>()();
|
||||||
|
|
||||||
|
test_main_template<boost::intrusive::smart_ptr<void>, false, true>()();
|
||||||
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
test_main_template<boost::intrusive::smart_ptr<void>, true, true>()();
|
||||||
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
// test (bounded pointers) x ((nonconst/const size) x (special node allocator)
|
||||||
test_main_template_bptr< true >()();
|
test_main_template_bptr< true >()();
|
||||||
test_main_template_bptr< false >()();
|
test_main_template_bptr< false >()();
|
||||||
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user