Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg
MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57131] Fri, 28 May 2021 12:34 Go to next message
wqcmaster is currently offline  wqcmaster
Messages: 37
Registered: March 2013
Member
Hi,

is there an error here?
No error is thrown under the CLANG compiler; if the MSVS15x64 compiler is used, several errors are thrown.

Upp Version: 15947
Package Core
File "Fn.h"

template <class T, class K, typename... L>
constexpr int findarg(const T& sel, const K& k, const L& ...args)
{
	if(sel == k)
		return 0;
	int q = findarg(sel, args...);
	 return q >= 0 ? q + 1 : -1;
}


threw the following error:
...Fn.h (58): error C3256: "q": Variablenverwendung ergibt keinen konstanten Ausdruck
...Fn.h (53): error C3259: "constexpr"-Funktionen können nur eine return-Anweisung aufweisen.
...Fn.h (57): error C3250: "q": Deklaration ist im "constexpr"-Funktionstext nicht zulässig


But if the function is changed as follows:
template <class T, class K, typename... L>
constexpr int findarg(const T& sel, const K& k, const L& ...args)
{
	return (sel == k) ? 0 : findarg(sel, args...) >= 0 ? findarg(sel, args...) + 1 : -1;
}

-> no error is displayed when compiling.

[Updated on: Fri, 28 May 2021 12:40]

Report message to a moderator

Re: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57149 is a reply to message #57131] Mon, 31 May 2021 20:06 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
In your fix you are using C++11. It supports very limited syntax with constexpr, basically, only what fits into a return statement.
Current code in U++ is using C++14, which allows to use almost all C++ statements with constexpr.


Regards,
Novo
Re: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57150 is a reply to message #57149] Mon, 31 May 2021 20:08 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
Basically, U++ requires C++14.

Regards,
Novo
Re: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57151 is a reply to message #57150] Mon, 31 May 2021 20:12 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
There was a good presentation about constexpr on CppCon 2015, I believe ...

Regards,
Novo
icon14.gif  Re: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57153 is a reply to message #57151] Tue, 01 June 2021 10:08 Go to previous messageGo to next message
wqcmaster is currently offline  wqcmaster
Messages: 37
Registered: March 2013
Member
Thanks for the information,
Most of the time I use the CLANG compiler myself. I will update the MS Compiler soon, thanks to your information.
Re: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57155 is a reply to message #57153] Tue, 01 June 2021 15:54 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
An /std (Specify Language Standard Version) can be handy as well.

Regards,
Novo
Re: MSVS15x64: Compile Error C3256 C3259 C3250 in Fn.h findarg [message #57174 is a reply to message #57155] Fri, 04 June 2021 06:07 Go to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
Just in case: CppCon 2015: Scott Schurr "constexpr: Introduction"

Regards,
Novo
Previous Topic: SIGPIPE problem
Next Topic: Jsonize() Date and Time serialization [patch]
Goto Forum:
  


Current Time: Thu Apr 25 13:48:42 CEST 2024

Total time taken to generate the page: 0.02852 seconds