§10.4/3 дает все возможные ситуации, которые подробно рассмотрены декларированием. Однако я не могу полностью это понять. Рассмотрим пример, описанный в §10.4/6:
исходный файл foo.h :
namespace N {
struct X {};
int d();
int e();
inline int f(X, int = d()) { return e(); }
int g(X);
int h(X);
}
< /code>
Интерфейс модуль M: < /p>
module;
#include "foo.h"
export module M;
template int use_f() {
N::X x; // N::X, N, and :: are decl-reachable from use_f
return f(x, 123); // N::f is decl-reachable from use_f,
// N::e is indirectly decl-reachable from use_f
// because it is decl-reachable from N::f, and
// N::d is decl-reachable from use_f
// because it is decl-reachable from N::f
// even though it is not used in this call
}
template int use_g() {
N::X x; // N::X, N, and :: are decl-reachable from use_g
return g((T(), x)); // N::g is not decl-reachable from use_g
}
template int use_h() {
N::X x; // N::X, N, and :: are decl-reachable from use_h
return h((T(), x)); // N::h is not decl-reachable from use_h, but
// N::h is decl-reachable from use_h
}
int k = use_h();
// use_h is decl-reachable from k, so
// N::h is decl-reachable from k
Module M implementation:
module M;
int a = use_f(); // OK
int b = use_g(); // error: no viable function for call to g;
// g is not decl-reachable from purview of
// module M's interface, so is discarded
int c = use_h(); // OK
Почему n :: g не декларируется от use_g ? Почему n :: h не предоставляется декларированием от use_h , но n :: h является декларированием от use_h ? Почему §10.4/(3.2) или §10.4/(3.3) не применяется к ним?
§10.4/3 дает все возможные ситуации, которые подробно рассмотрены декларированием. Однако я не могу полностью это понять. Рассмотрим пример, описанный в §10.4/6: исходный файл foo.h : [code]namespace N { struct X {}; int d(); int e(); inline int f(X, int = d()) { return e(); } int g(X); int h(X); } < /code> Интерфейс модуль M: < /p> module; #include "foo.h" export module M; template int use_f() { N::X x; // N::X, N, and :: are decl-reachable from use_f return f(x, 123); // N::f is decl-reachable from use_f, // N::e is indirectly decl-reachable from use_f // because it is decl-reachable from N::f, and // N::d is decl-reachable from use_f // because it is decl-reachable from N::f // even though it is not used in this call } template int use_g() { N::X x; // N::X, N, and :: are decl-reachable from use_g return g((T(), x)); // N::g is not decl-reachable from use_g } template int use_h() { N::X x; // N::X, N, and :: are decl-reachable from use_h return h((T(), x)); // N::h is not decl-reachable from use_h, but // N::h is decl-reachable from use_h } int k = use_h(); // use_h is decl-reachable from k, so // N::h is decl-reachable from k
Module M implementation: module M; int a = use_f(); // OK int b = use_g(); // error: no viable function for call to g; // g is not decl-reachable from purview of // module M's interface, so is discarded int c = use_h(); // OK
[/code] Почему n :: g не декларируется от use_g ? Почему n :: h не предоставляется декларированием от use_h , но n :: h является декларированием от use_h ? Почему §10.4/(3.2) или §10.4/(3.3) не применяется к ним?