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 » Community » Newbie corner » Compile time hash macro
Compile time hash macro [message #56341] Tue, 23 February 2021 17:55 Go to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello U++ !

Is there a way in U++ to do hashing of String during compilation ?

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	Cout() << GetHashValue ("Hello") << EOL; //Runtime hashing
	Cout() << HASH64("Hello") << EOL; //Compile time hashing
	//Both value printed should be identique
}
Re: Compile time hash macro [message #56342 is a reply to message #56341] Tue, 23 February 2021 18:07 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
Not right now. But you can try to reimplement function hash_t memhash(const void *ptr, size_t count) as constexpr.
If you do that it will be possible to call it at compile time.


Regards,
Novo
Re: Compile time hash macro [message #56343 is a reply to message #56342] Tue, 23 February 2021 18:08 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Thanks, I will look to implement this
Re: Compile time hash macro [message #56389 is a reply to message #56342] Wed, 03 March 2021 10:06 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Novo wrote on Tue, 23 February 2021 18:07
Not right now. But you can try to reimplement function hash_t memhash(const void *ptr, size_t count) as constexpr.
If you do that it will be possible to call it at compile time.


NOTE: String is not using (only) memhash, so the value would not be the same.

Mirek
Previous Topic: error: call to implicitly-deleted copy constructor
Next Topic: deprecated function encountered
Goto Forum:
  


Current Time: Thu Mar 28 22:57:58 CET 2024

Total time taken to generate the page: 0.01004 seconds