This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


1890. Member type depending on definition of member function

Section: 11.4  [class.mem]     Status: drafting     Submitter: Hubert Tong     Date: 2014-03-07

Consider an example like:

  struct A {
    struct B {
      auto foo() { return 0; }
    };
    decltype(B().foo()) x;
  };

There does not appear to be a prohibition of cases like this, where the type of a member depends on the definition of a member function.

(See also issues 1360, 1397, and 2335.)

Additional notes (January, 2023):

The following example might be related:

  #include <type_traits>

  struct Bar {
    struct Baz {
      int a = 0;
    };
    static_assert(std::is_default_constructible_v<Baz>);
  };

Additional notes (November, 2023):

The following example is also rejected by implementations, but it is allowed by the rules:

    struct A {
      static bool f2() { return f(); }

      static consteval bool f() { return true; }
    };