Dec 11, 2014 at 2:33pm UTC
The following piece of code is giving error in visual studio but not in cpp.sh website.
error on line 27 of code : function call must have a constant value in a constant expression
link_code :
http://cpp.sh/2nnk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <iostream>
class Data
{
int d_x;
public :
constexpr Data(int x):d_x(x)
{}
int constexpr cMember()
{
return d_x;
}
int member() const
{
return d_x;
}
};
int main(){
constexpr Data d2(0);
enum e2 {
OK = d2.cMember(),
};
std::cout<<OK;
}
Is it a bug in visual studio??
Last edited on Dec 11, 2014 at 2:36pm UTC
Dec 11, 2014 at 2:44pm UTC
Last edited on Dec 11, 2014 at 2:45pm UTC
Dec 11, 2014 at 3:00pm UTC
ohh thanks !i was using vs 2013 community edition , with everything updated ....i wont be updating with the above given link because it has the latest c++14 features (to be tested)
Last edited on Dec 11, 2014 at 3:03pm UTC