This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [c++-concepts]: constraint association
- From: Gabriel Dos Reis <gdr at axiomatics dot org>
- To: Andrew Sutton <andrew dot n dot sutton at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 22 Jun 2013 12:11:40 -0500
- Subject: Re: [c++-concepts]: constraint association
- References: <CANq5SyuYuaXwGBZd+rCo34QRsL8q97Q222tCMCJ9tog8vycL-g at mail dot gmail dot com> <CAAiZkiBurK7LwVnQm7bQt7=9Abx-ZUXgCUoBBgqDdiqbYWqMGg at mail dot gmail dot com> <CANq5SyvftTCef53d2w-zoMcZZBPu5dGhC9ftXaZt1Kn0d3D__w at mail dot gmail dot com>
Andrew Sutton <andrew.n.sutton@gmail.com> writes:
| I the long term, I think we'll end up having constraints attached to
| declarations wherever we constrain auto (PARM_DECL, VAR_DECL, etc).
| Although now that I'm looking, it seems that lang_decl_parm does not
| inherit lang_min. Hmm...
|
| Mostly, though, I'm not sure where I could put it where both
| TEMPLATE_DECL and FUNCTION_DECL would have constraints.
I think we want constraints for:
* FUNCTION_DECL
* TEMPLATE_DECL
* TYPE_DECL
* TEMPLATE_PARM_DECL
Internally, we want to always store the canonical form of a decl, not the
source-level form -- the current g++ AST isn't prepared for that (I wish
it was, but it isn't.) This allows for simple comparison and other
semantics processing.
When we have
void sort(Range& r);
and Range is a unary concept, this make 'sort' a TEMPLATE_DECL. I am
not sure we actually want to make the PARM_DECL 'r' to have a constraint.
Rather, we want the internal representation to store the canonical form:
template<typename __T1> requires Range<__T1>
void sort(__T1& r);
so that the PARM_DECL 'r' never gets a constraint -- it is its type that
is constrained. This way, duplicate_decls for example won't need extensive
surgery to remain unconfused.
-- Gaby