Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6068101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:40:46+00:00 2026-05-23T09:40:46+00:00

Basically I need a truly compile-time string hashing in C++. I don’t care about

  • 0

Basically I need a truly compile-time string hashing in C++. I don’t care about technique specifics, can be templates, macros, anything. All other hashing techniques I’ve seen so far can only generate hashtable (like 256 CRC32 hashes) in compile time, not a real hash.

In other words, I need to have this

printf("%d", SOMEHASH("string"));

to be compiled as (in pseudo-assembler)

push HASHVALUE
push "%d"
call printf

even in Debug builds, with no runtime operations on string. I am using GCC 4.2 and Visual Studio 2008 and I need the solution to be OK for those compilers (so no C++0x).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:40:47+00:00Added an answer on May 23, 2026 at 9:40 am

    The trouble is that in C++03 the result of subscripting a string literal (i.e. access a single character) is not a compile-time constant suitable for use as a template parameter.

    It is therefore not possible to do this. I would recommend you to write a script to compute the hashes and insert them directly into the source code, i.e.

    printf("%d", SOMEHASH("string"));

    gets converted to

    printf("%d", 257359823 /*SOMEHASH("string")*/ ));

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I need a hosted solution, where one can create an account for a
I basically need a function to check whether a string's characters (each character) is
I have a unicode string in Python and basically need to go through, character
I've looked EVERYWHERE for this, can't find anything. I basically need to store an
We basically need to be able to adjust behaviour at start-up time, by providing
I basically need to get current date and time separately, formatted as: 2009-04-26 11:06:54
I basically need to show some information about the current game in a separate
Basically need to generate custom(some different then yes no) messeges(alert) in JS , how
basically need to change the value that - admin_url() returns any idea?
I basically need to highlight a particular word in a block of text. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.