Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: constexpr static member function

Reply
Thread Tools

Re: constexpr static member function

 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-01-2013
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-02-2013
On 3/2/2013 4:09 AM, Juha Nieminen wrote:
> Victor Bazarov <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: constexpr static member function Luca Risolia C++ 0 03-02-2013 12:26 PM
Re: constexpr static member function Victor Bazarov C++ 0 03-01-2013 05:02 PM
Can a static member function access non-static member? dolphin C++ 3 12-05-2007 12:39 PM
How do you call a regular member function from a static member function? aling C++ 6 10-30-2005 04:38 AM
performance of static member function vs. instance member function 0to60 C++ 4 11-21-2003 05:25 PM



Advertisments