home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,850 of 33,346   
   =?ISO-8859-1?Q?=D6=F6_Tiib?= to Luca Risolia   
   Re: Does constexpr bloat the code?   
   04 Feb 13 09:06:18   
   
   From: ootiib@hot.ee   
      
   On Monday, 4 February 2013 08:44:44 UTC+2, Luca Risolia  wrote:   
   > On 04/02/2013 00:18, DeMarcus wrote:   
   > > I perceive constexpr as an advanced meta-programming "#define" or   
   > > "macro" that replaces the expression with some compile-time computed value.   
   >   
   > Not in general. constexpr is also a function modifier. Although a   
   > constexpr function can be used in constant expressions, this does not   
   > mean that all uses are constant expressions.   
   >   
   > For example:   
   > constexpr int f(int x) { return x+x; }   
   > int a[f(5)]; // okay   
   > int v = 5;   
   > int a[f(v)]; // not ok, v is not a constant expression   
      
   That example fails to support your point.   
   Macro can be also function-like. ;)   
      
     #define F(X) ((X)+(X))   
     int a[F(5)]; // okay   
     int v = 5;   
     int a[F(v)]; // not ok, v is not a constant expression   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca