Re: constexpr static member function

Discussion in 'C++' started by Victor Bazarov, Mar 1, 2013.

  1. On 3/1/2013 11:19 AM, Juha Nieminen wrote:
    > For some reason this doesn't compile with the latest clang:
    >
    > class MyClass
    > {
    > public:
    > static constexpr int something(int);
    > };
    >
    > constexpr int MyClass::something(int i) { return i+1; }
    >
    > The error message is "Conflicting types for 'something'".
    >
    > Is this a limitation in clang, in C++11, or am I using the wrong syntax?


    Another thought, [dcl.constexpr]/2 states that "constexpr functions and
    constexpr constructors are implicitly inline (7.1.2)." Perhaps you need
    to define it inside the class...

    V
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Mar 1, 2013
    #1
    1. Advertisements

  2. On 3/2/2013 4:09 AM, Juha Nieminen wrote:
    > Victor Bazarov <> wrote:
    >> Another thought, [dcl.constexpr]/2 states that "constexpr functions and
    >> constexpr constructors are implicitly inline (7.1.2)." Perhaps you need
    >> to define it inside the class...

    >
    > I would prefer knowledge over guessing.


    Wouldn't we all?

    > "Implicitly inline" means, as I understand it, "inline without having
    > to explicitly specify that keyword."


    As I understand it, a function cannot be explicitly or implicitly inline
    if you don't provide its body.

    V
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Mar 2, 2013
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newsgroup - Ann
    Replies:
    5
    Views:
    880
    John Carson
    Jul 30, 2003
  2. slide_o_mix
    Replies:
    0
    Views:
    577
    slide_o_mix
    Oct 15, 2003
  3. Alex
    Replies:
    0
    Views:
    530
  4. 0to60
    Replies:
    4
    Views:
    723
    jeffc
    Nov 21, 2003
  5. aling
    Replies:
    6
    Views:
    636
    Xiaobin.Huang
    Oct 30, 2005
  6. dolphin
    Replies:
    3
    Views:
    1,623
    Pete Becker
    Dec 5, 2007
  7. paul
    Replies:
    8
    Views:
    885
    Alf P. Steinbach
    Apr 30, 2009
  8. A L
    Replies:
    12
    Views:
    2,413
Loading...