Reputation: 70078
I have a header file, whose functionality relies heavily on the success of SFINAE. In present g++ 4.6
it works as expected. Should I assume that, my code will behave seamlessly in the same way for all compilers (C++03 compilers) ?
I find this as an issue, because if something differs it won't result in compiler error and silently would change the code flow.
Upvotes: 1
Views: 271
Reputation: 385325
Yes, you may rely on SFINAE to exist and function properly.
If you have a compiler that fails at it, then it's terminally non-conformant and all bets are off anyway.
Upvotes: 4
Reputation: 64273
Since it depends on the success of the SFINAE, you should use static_assert
(or BOOST_STATIC_ASSERT
) to make sure the SFINAE passed successfully.
I do not know if your code would work on all compilers, but the static assert would fail the compilation if a specific compiler fails to produce expected output for specific SFINAE.
Upvotes: 0