3

The following code compiles and runs just fine with GCC 8.3 and with Clang 10.0.1, whereas it fails miserably on MicroSoft shiny compiler.

#include <vector>
#include <range/v3/view/group_by.hpp>

int main(){
    std::vector<int> edits{1,1,3,2,2,4,4,4,4,1,1,3,3,2};
    auto xxx = ranges::subrange(edits.begin(), edits.end());
}

Is there some flag that I'm missing?

Enlico
  • 23,259
  • 6
  • 48
  • 102

1 Answers1

2

You've specified /std:c++17 and ranges::subrange is not present in C++ 17. Ranges-v3 also requires C++ 20 because it uses Concepts.

Compiling instead with /std:c++latest succeeds.

The errors turn out to be coming from a Concepts emulation layer bundled in Ranges v3, which evidently does not work correctly on the latest Visual C++'s C++17 mode. According to the documentation, it needed experimental compiler options even when it did work, so best to just turn on C++ 20 support when using Microsoft's compiler.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • I might have misunderstood you answer. Obviously `std::ranges::whatever` comes with C++20, not C++17, but what I use in my example is the Range-v3 library, not C++20 ranges library, and that does work in C++17. Nonetheless your suggestion of using the `/std:c++latest` fix the issue. Can you explain a bit more? – Enlico Feb 12 '21 at 18:29
  • You mean that `#include ` is being processed as it was `#include `??? – Enlico Feb 12 '21 at 18:33
  • And why do the other two compilers just fine with `-std=c++17`? – Enlico Feb 12 '21 at 18:44
  • 1
    @Enlico: Maybe the `concepts/concepts.hpp` header included in Ranges v3 isn't broken on those compilers? Maybe those compilers enable too many featuers in C++17 mode? – Ben Voigt Feb 12 '21 at 18:47