microsoft / Range-V3-VS2015

A fork of the popular range-v3 C++ library with support for the Visual Studio 2015 Update 3 VC++ compiler.
Other
115 stars 22 forks source link

`action::push_back` is a silent no-op rather than compile-time error on incompatible containers #33

Open cstratopoulos opened 6 years ago

cstratopoulos commented 6 years ago

The following snippet was tested with Visual Studio 2017 15.6.6.

#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <range/v3/action/push_back.hpp>

#include <set>

int main()
{
    std::set<int> s;
    ranges::action::push_back(s, 1);

    return s.size();
}

This successfully compiles with std:cpp14 or std:cpp17 and returns zero.

Expected behavior is a compile-time error with a static assertion related to std::set not satisfying the concept/ADL detection for push_back.

Oddly, if the first #define is commented out, compilation fails due to the macro not being defined, but also with the expected static assertion.

I am not sure if this is a bug with Range-V3-VS2015 or with MSVC itself. On g++7.2 the code fails at compile time with the expected static assertion failure.