C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Proposal of constpub (DRAFT 1)
From: Matthew Woehlke (mwoehlke.floss_at_[hidden])
Date: 2020-01-15 10:08:19


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

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups