1

I'm trying to use the function traits that was posted as the marked answer here: Is it possible to figure out the parameter type and return type of a lambda?

While trying to compile it with msvc 19.16.27034 I get the following errors:

Error   C2825   'T': must be a class or namespace when followed by '::'
Error   C2510   'T': left of '::' must be a class/struct/union
Error   C2065   '()': undeclared identifier
Error   C2955   'function_traits': use of class template requires template argument list

On godbolt this works on any compiler but for some reason on my local machine I can't get this to compile because of these errors. Am I missing something?

UPDATE:

Adding std::remove_reference_t

    template <typename T>
    struct function_traits
        : public function_traits<decltype(&std::remove_reference_t<T>::operator())>
    {
    };

to the declaration solves the problem.

The weird part is that even without any instantiation to the template I still get this error on the specified compiler, unless I'm adding std::remove_reference_t.

Anyone can explain this weird behaviour?

Jorayen
  • 1,737
  • 2
  • 21
  • 52
  • [Can't reproduce](https://godbolt.org/z/Paa_R3). The code from that answer compiles for me exactly as written, without any changes. – Igor Tandetnik Jun 12 '20 at 15:03
  • @IgorTandetnik well you don't have to repeat what I already said. I said I only experience this locally and not on godbolt, maybe someone could reproduce locally with the compiler version I've given and the code without `std::remove_reference_t`. – Jorayen Jun 12 '20 at 15:22

0 Answers0