fixing issues in MSVC, adding comments in MSVC-failing examples

This commit is contained in:
badair
2016-03-31 01:47:45 -05:00
parent 040dfe0088
commit 9cc2840b31
8 changed files with 196 additions and 55 deletions

View File

@@ -7,6 +7,10 @@ Distributed under the Boost Software License, Version 1.0.
#include <type_traits>
#include <callable_traits/callable_traits.hpp>
// NOTE: Due to non-compliance in MSVC, can_invoke_constexpr
// always return std::false_type on that compiler, which causes
// the static asserts below to fail.
namespace ct = callable_traits;
using T1 = std::integral_constant<int, 3>;
@@ -20,7 +24,7 @@ struct subtract {
// must have a SFINAE-safe signature. In this case, 'subtract' is made
// SFINAE-safe with an explicit, trailing return type.
template<typename T1, typename T2>
constexpr auto operator()(T1, T2) -> decltype(T1::value - T2::value) {
constexpr auto operator()(T1, T2) const -> decltype(T1::value - T2::value) {
return T1::value - T2::value;
}
};
@@ -35,7 +39,7 @@ static_assert(!ct::can_invoke_constexpr(subtract{}, T1{}), "");
//this is a function object, but is NOT constexpr
struct add {
template<typename T1, typename T2>
auto operator()(T1, T2) -> decltype(T1::value + T2::value) {
auto operator()(T1, T2) const -> decltype(T1::value + T2::value) {
return T1::value + T2::value;
}
};
@@ -64,4 +68,4 @@ using S_result = decltype(ct::can_invoke_constexpr(std::declval<S>()));
static_assert(S_result::value, "");
*/
int main() {}
int main() {}