0

I am using vs2017, when using reduce function:

     auto norm = 1.f / std::reduce(t_, t_ + channels);

and the header is:

     #include "numeric"

I got below error:

error   c2039   “reduce”: is not member of std.

but as far as I know, reduce function has been added in c++17. What should I do?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
shelmin.Y
  • 3
  • 2
  • Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. Feel free to drop me a comment in case you have further questions or feedback for me. – GhostCat Sep 17 '18 at 07:50
  • 2
    Please read [no pictures of exceptions](http://idownvotedbecau.se/imageofanexception/) / [no pictures of code](http://idownvotedbecau.se/imageofcode). Then use the [edit] link to replace screen shots of text with nicely formatted/indented text within your question. – GhostCat Sep 17 '18 at 07:50
  • Have you included the requisite headers? – n. m. could be an AI Sep 17 '18 at 08:17
  • There are the headers: #include "numeric" – shelmin.Y Sep 17 '18 at 08:20

1 Answers1

1

You should use #include <numeric> instead of #include "numeric" <> is for system includes, "" is for local headers.

Second thing is that VS2017 does not have full support for c++17 and that's the problem I guess. Also make sure you have enabled c++17 switch How to enable C++17 compiling in Visual Studio?

Michał Walenciak
  • 4,257
  • 4
  • 33
  • 61
  • thanks! I guess I didn't get the full support for c++17.I'll try to solve that and compile again. – shelmin.Y Sep 17 '18 at 09:02
  • 1
    Please do not propagate the idea that `<>` is for system headers and `""` for local ones. *Both* are totally implementation defined in the C and C++ standards as to how headers are located. – paxdiablo Sep 17 '18 at 09:08
  • 2
    @paxdiablo Except `#include ` has a fixed meaning under the standard, while `#include "algorithm"` doesn't. – Yakk - Adam Nevraumont Sep 17 '18 at 17:31