Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14910

Re: constepxr | Isn't this a constant expression?

From darylew@gmail.com
Newsgroups comp.lang.c++
Subject Re: constepxr | Isn't this a constant expression?
Date 2012-03-12 06:22 -0700
Organization http://groups.google.com
Message-ID <10078092.2831.1331558537859.JavaMail.geo-discussion-forums@vbgu10> (permalink)
References <b673c645-fdbc-439d-8371-3fa938835798@ud10g2000pbc.googlegroups.com>

Show all headers | View raw


On Sunday, March 11, 2012 6:40:42 AM UTC-4, Samkit Jain wrote:
> Compiler: gcc 4.6.1
> 
> Code:
> 
> struct data
> {
>     constexpr data(int i) :i_(i) {}
>     int i_;
> };
> 
> template <typename T, int Size>
> constexpr void const* get_addr(T const (&elements)[Size]) { return
> (void const*)elements; }
> 
> template <typename T>
> constexpr void const* get_addr(T const& element) { return (void
> const*)&element; }

IIUC, constexpr stuff is only for value semantics.  Addresses are for identity semantics, so constexpr is ignored.  Compile-time evaluations are done generally before object addresses are finalized, so pointer stuff can't really ever be constexpr.

Daryle W.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

constepxr | Isn't this a constant expression? Samkit Jain <samkit.feeds@gmail.com> - 2012-03-11 03:40 -0700
  Re: constepxr | Isn't this a constant expression? darylew@gmail.com - 2012-03-12 06:22 -0700
  constepxr | Isn't this a constant expression? Johannes Schaub - litb <schaub.johannes@googlemail.com> - 2012-03-13 23:52 -0700
    Re: constepxr | Isn't this a constant expression? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-03-14 20:03 -0700
      Re: constepxr | Isn't this a constant expression? Samkit Jain <samkit.feeds@gmail.com> - 2012-03-15 10:04 -0700
        Re: constepxr | Isn't this a constant expression? Johannes Schaub <schaub.johannes@googlemail.com> - 2012-03-16 23:16 +0100
          Re: constepxr | Isn't this a constant expression? Samkit Jain <samkit.feeds@gmail.com> - 2012-03-18 08:09 -0700
    Re: constepxr | Isn't this a constant expression? Miles Bader <miles@gnu.org> - 2012-03-16 09:46 +0900

csiph-web