Open pikacic opened 1 year ago
As a side note, the error mentions:
/cvmfs/sft-nightlies.cern.ch/lcg/views/dev4/Mon/x86_64-el9-gcc13-dbg/include/concepts/compare.hpp:35:39: error: reference to 'ranges' is ambiguous
concept compares_as = same_as<ranges::common_comparison_category_t<T, Cat>, Cat>;
^
Shouldn't this header file also be improved by fully qualifying ranges here? (i.e. would the same problem happens in a compilation unit where the user of this header and string_view
want to use using namespace std;
?
Yes, of course, I can reproduce the error in regular C++ with something as simple as https://godbolt.org/z/rnqWer3bj:
#include <ranges>
using namespace std;
#include <range/v3/views.hpp>
but I see 2 errors in this example:
using namespace std
before including range/v3/views.hpp
(actually using namespace std
should be considered an error by itself).The following code works:
#include <ranges>
#include <range/v3/views.hpp>
using namespace std;
still a bit silly, but it works.
So, I'm sorry, but I do not buy the comment that developers of libraries should always put ::
in front of every top level namespace. I believe it is fairy reasonable to assume that nobody does using namespace std;
before including any header.
Yes, it is still true that we need to remove/replace the using namespace
(my note was just a side note and was not meant to undermine this report) and it is also true that making one's own headers more resilient to silly but legal usage is usually worth the slight (and debatable) decrease in readability (by having/adding more qualification).
Check duplicate issues.
Describe the bug
Because of the implicit
using namespace std
in the interpreter, trying to use range-v3 headers result in errors about ambiguous references, like:What is the expected behaviour?
I expect to be able to use the top level
ranges
namespace at the same time asstd::ranges
.How to reproduce?
From lxplus9.cern.ch
ROOT version
v6-28-00-patches
How did you install ROOT?
LCG nightly builds in /cvmfs/sft-nightlies.cern.ch
Which operating system are you using?
Linux Alma 9
Additional context
I wanted to report this problem as a compelling use case that requires #11027