const expression error

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
Which version of VS? VS does not support constexpr yet: http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx

Partial? support for constexpr was added in November 2013 CTP
http://www.microsoft.com/en-us/download/details.aspx?id=41151
Last edited on
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
Topic archived. No new replies allowed.