Naios / function2

Improved and configurable drop-in replacement to std::function that supports move only types, multiple overloads and more
http://naios.github.io/function2
Boost Software License 1.0
539 stars 47 forks source link

Allow configuring for AppleClang #42

Closed madmongo1 closed 3 years ago

madmongo1 commented 3 years ago

@Naios

Running CMake on function2 causes a failure if you select the generator -G Xcode while on an apple mac. This is because the CMAKE_COMPILER_ID for Apple's compiler is AppleClang.


What was a problem?

Failure to configure when using Apple Clang.

How this PR fixes the problem?

Modify the check for Clang to use a regex match on "Clang" so that it captures both AppleClang and Clang

Check lists (check x in [ ] of list items)

Additional Comments (if any)

No tests required - the test is the fact that the project now configures correctly on a mac and continues to configure correctly on other Clang environments.

Naios commented 3 years ago

Thanks

madmongo1 commented 3 years ago

BTW, now that it builds, I get these test failures on AppleClang. Thought you'd like to know:

[----------] Global test environment tear-down
[==========] 527 tests from 119 test cases ran. (60 ms total)
[  PASSED  ] 513 tests.
[  FAILED  ] 14 tests, listed below:
[  FAILED  ] AllMoveAssignConstructTests/3.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<unique_no_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/3.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<unique_no_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/7.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<unique_256_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/7.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<unique_256_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/11.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<unique_512_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/11.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<unique_512_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/24.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<copyable_no_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/24.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<copyable_no_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/28.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<copyable_256_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/28.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<copyable_256_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/32.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<copyable_512_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/32.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<copyable_512_sfo, std_function>
[  FAILED  ] AllMoveAssignConstructTests/36.AreEmptyAfterMoveConstruct, where TypeParam = LeftRightType<std_function, std_function>
[  FAILED  ] AllMoveAssignConstructTests/36.AreEmptyAfterMoveAssign, where TypeParam = LeftRightType<std_function, std_function>

14 FAILED TESTS
Program ended with exit code: 1
Naios commented 3 years ago

If the failing lines are the following: https://github.com/Naios/function2/blob/fb903bbf00109c294f2a0dc742d968bf52be3883/test/assign-and-constructible-test.cpp#L90 https://github.com/Naios/function2/blob/fb903bbf00109c294f2a0dc742d968bf52be3883/test/assign-and-constructible-test.cpp#L104 then this error can be safely ignored and we need to add an exception for it in the unit tests.

It seems like the std::function of your standard library is not reset when it is moved which is also not guaranteed by the standard (as far as I know).

madmongo1 commented 3 years ago

OK, thanks. Apple Clang defaults to (some version of) libc++.