C++ Logo

std-proposals

Advanced search

Re: Proposal of constpub (DRAFT 1)

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Wed, 15 Jan 2020 11:08:19 -0500
On 14/01/2020 19.10, Henry Miller via Std-Proposals wrote:
> Today I want to store radius, next year I may discover circumference
> has some advantage in my application. Proposals that require me to
> actually have the member in question are thus suspect because they
> limit my future self. Thus I think C++ code guidelines should adopt a
> don't use it rule for any syntax that doesn't allow such changes.
> Most of the time it won't matter, but pitty the poor programmer who
> made the wrong choice and need to change thousands of x=c.x to
> x=c.getx(), (particularly if tools fail to work for whatever reason)

  // Today
  using radius = std::identity{}(m_r); // prevent taking address

  // Next year
  using radius = (m_c / std::math::pi);

QED

(Of course, this is a BIC...)

-- 
Matthew

Received on 2020-01-15 10:10:53