Skip to content

[namespace.std] Reopening a namespace within std #8714

@frederick-vs-ja

Description

@frederick-vs-ja

Is the following example well-defined?

#include <ranges>

class MyClass;

namespace std::ranges {
  template<>
  inline constexpr bool disable_sized_range<MyClass> = true;
}

It seemingly violates [namespace.std]/1 by defining the ranges namespace in std. I guess an LWG issue would be needed if we want to allow it.

If we want to keep it disallowed, perhaps it would be helpful to add an example with correction.

E.g.

#include <ranges>

class MyClass;

namespace std::ranges { // undefined behavior (or ill-formed, no diagnostic required): defining a namespace in std
  template<>
  inline constexpr bool disable_sized_range<MyClass> = true;
}

template<>
inline constexpr bool std::ranges::disable_sized_range<MyClass> = true; // OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions