From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.devel Subject: Re: Help sought from C++ expert: is this `value' a type or something else (what)? Date: Thu, 19 Jan 2023 10:41:15 -0500 Message-ID: <87pmbav8f8.fsf@md5i.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8661"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 19 16:42:10 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIX3J-0001we-7p for ged-emacs-devel@m.gmane-mx.org; Thu, 19 Jan 2023 16:42:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIX2e-0007tv-PE; Thu, 19 Jan 2023 10:41:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIX2X-0007tl-N1 for emacs-devel@gnu.org; Thu, 19 Jan 2023 10:41:21 -0500 Original-Received: from md5i.com ([75.151.244.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIX2V-0005m7-UD for emacs-devel@gnu.org; Thu, 19 Jan 2023 10:41:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=md5i.com; s=dkim; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=CkBtMQc2mlAEn0Ihnk6jq1dH3z0rf3nTr8TqAgpZO4Y=; b=kb12ra/+irMb2oCwuE3UTgJ7xB hCBLD1K+g3r98OKEgSIYYm8I40wuDjkyj+ETxIZ9Dh+vfXK3WD1Jkin3ajA3FHev5Ezre1iSEs4+f /8SqGNWAD3lPs8GhaSynZ9VEE; Original-Received: from abode ([192.168.177.1]:48948 helo=miko) by md5i.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pIX2S-00DORw-1V; Thu, 19 Jan 2023 10:41:16 -0500 In-Reply-To: (Alan Mackenzie's message of "Thu, 19 Jan 2023 14:53:22 +0000") Received-SPF: pass client-ip=75.151.244.229; envelope-from=mwd@md5i.com; helo=md5i.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302552 Archived-At: Alan Mackenzie writes: > In the following test file, templates-9.cc from the CC Mode test suite, > on the indicated line, what is the syntactic significance of `value'? Here `value' is a value, specifically a boolean struct member. This is boost's implementation of what became, in C++11, `std::is_same', which can be found documented here: https://en.cppreference.com/w/cpp/types/is_same > Traditionally, it has fontified with the default face, but recently after > some (not yet committed) changes in CC Mode, it has started getting > font-lock-type-face. > > I don't understand the file at all, hardly, and can't work out whether > the old (non-) fontification was correct, or whether the new > fontification of f-l-type-face is correct. Help would be appreciated. Given a name `Foo', the compiler doesn't necessarily know if `Foo::bar' is a type or a value, because it doesn't necessarily know what type Foo is - it could be a template argument, for example, and won't be known until an instance is referenced. The assumption is that it is a value. If it was a type, this is pointed out to the compiler by calling it `typename Foo::bar'. For more on this, see: https://en.cppreference.com/w/cpp/language/dependent_name >From that page, "In a declaration or a definition of a template, including alias templates, a name that is not a member of the current instantiation and is dependent on a template parameter is not considered to be a type unless the keyword `typename' is used or unless it was already established as a type name, e.g. with a typedef declaration or by being used to name a base class." > Just as a matter of interest, in c++-ts-mode a treesit-query-error gets > thrown. It isn't clear to me whether the file is still valid C++. It looks valid. The `template' before the `then' is, like `typename' a disambiguator for the dependent name `then', stating that it is a template name. > ///////////////////////////////////////////////////////////////////////// > typedef std::pair , std::pair , std::pair , std::pair > > > > > > list_of_types; > > typedef std::pair< > int, std::pair< > long, std::pair< > char*, std::pair > > > > >> list_of_types; > > typedef typename if_true > < > boost::is_same > < > boost::add_pointer > , int* > >::value // <=================================================== >>::template then > < > boost::remove_reference > // else > , X >>::type modified_X; > ///////////////////////////////////////////////////////////////////////// > > Thanks! -- Michael Welsh Duggan (md5i@md5i.com)