MSVC doesn't seem to appreciate the macro-based solution I was given here to wrap a function template in a function object.
The macro is
#define FUNCTORIZE(func) [](auto&&... val) \
noexcept(noexcept(func(std::forward<decltype(val)>(val)...))) -> decltype(auto) \
{return func(std::forward<decltype(val)>(val)...);}
to be used (for instance) like this
template <std::size_t N>
inline constexpr auto get = FUNCTORIZE(std::get<N>);
so that one obtains a function object that can be passed around like this
std::transform(v.begin(), v.end(), w.begin(), get<1>);
And all works well in GCC and Clang, but MSVC errors like this:
<source>(12): error C2760: syntax error: unexpected token 'identifier', expected ')'
<source>(18): note: see reference to variable template 'const auto get<1>' being compiled
Compiler returned: 2
- Probably I'd just need to add some compiler flag (other than one specifying a newer standard than C++17)?
- Would writing the macro differently help?
- Can I get that macro working in C++17 with MSVC?