Skip to content

Commit

Permalink
Adding static casts for Visual C++
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-parent committed Oct 30, 2024
1 parent 09c1b7d commit c543759
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/unit_tests/functional/functional_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ struct test_binary_function {

} // namespace

/*
REVISIT(sean-parent) : The static casts are necessary to get this code to compile on VC++14.
It is unclear why the compiler is unable to find the enum operators.
*/


BOOST_AUTO_TEST_CASE(functional_transpose) {

// Test that the transpose functional object correctly transposes the arguments of a binary
// function. It also tests that the correct overload is selected and that the noexcept
// qualifier is correctly propagated.

transpose lvalue{test_binary_function<(_all ^ _lvalue)>{}};
const transpose const_lvalue{test_binary_function<(_all ^ _const_lvalue)>{}};
transpose lvalue{
test_binary_function<static_cast<member_function_qualifiers>(_all ^ _lvalue)>{}};
const transpose const_lvalue{
test_binary_function<static_cast<member_function_qualifiers>(_all ^ _const_lvalue)>{}};
transpose lvalue_noexcept{test_binary_function<_lvalue>{}};
const transpose const_lvalue_noexcept{test_binary_function<_const_lvalue>{}};

Expand All @@ -75,8 +82,11 @@ BOOST_AUTO_TEST_CASE(functional_transpose) {
BOOST_TEST((const_lvalue_noexcept(1, 2) == tuple(2, 1, _const_lvalue)));
BOOST_TEST(noexcept(const_lvalue_noexcept(1, 2)));

BOOST_TEST((transpose(test_binary_function<(_all ^ _rvalue)>{})(1, 2) == tuple(2, 1, _rvalue)));
BOOST_TEST(!noexcept(transpose(test_binary_function<(_all ^ _rvalue)>{})(1, 2)));
BOOST_TEST(
(transpose(test_binary_function<static_cast<member_function_qualifiers>(_all ^ _rvalue)>{})(
1, 2) == tuple(2, 1, _rvalue)));
BOOST_TEST(!noexcept(transpose(
test_binary_function<static_cast<member_function_qualifiers>(_all ^ _rvalue)>{})(1, 2)));

BOOST_TEST((transpose(test_binary_function<_rvalue>{})(1, 2) == tuple(2, 1, _rvalue)));
BOOST_TEST(noexcept(transpose(test_binary_function<_rvalue>{})(1, 2)));
Expand Down

0 comments on commit c543759

Please sign in to comment.