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. Advertising

  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. Advertising

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. 0to60
    Replies:
    4
    Views:
    504
    jeffc
    Nov 21, 2003
  2. aling
    Replies:
    6
    Views:
    467
    Xiaobin.Huang
    Oct 30, 2005
  3. dolphin
    Replies:
    3
    Views:
    1,327
    Pete Becker
    Dec 5, 2007
  4. Victor Bazarov

    Re: constexpr static member function

    Victor Bazarov, Mar 1, 2013, in forum: C++
    Replies:
    0
    Views:
    239
    Victor Bazarov
    Mar 1, 2013
  5. Luca Risolia

    Re: constexpr static member function

    Luca Risolia, Mar 2, 2013, in forum: C++
    Replies:
    0
    Views:
    173
    Luca Risolia
    Mar 2, 2013
Loading...

Share This Page