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

  • Home
  • SEARCH
  • 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 8620557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:36:39+00:00 2026-06-12T06:36:39+00:00

Say I have an object that takes about 30 seconds to construct on each

  • 0

Say I have an object that takes about 30 seconds to construct on each program run. This object is constructed with the same piece of data each and every time the program is run. What solution(s) exist for this problem?

EDIT:

I did some research tailored to a more specific version of my question. In particular, I wanted to populate a hash table with some values. I found http://www.gnu.org/software/gperf/ which addresses this exact issue. gperf generates a perfect hash function and the associated table to go along.

  • 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-06-12T06:36:40+00:00Added an answer on June 12, 2026 at 6:36 am

    C++11 introduces an extended notion of “constant expression”, which you can confer on objects by means of the constexpr keyword:

    constexpr int a = 12;      // constant expression
    
    constexpr int f(int n) { return a * n; }
    
    constexpr int b = f(a);    // also constant expression
    

    Objects may have constructors declared as constexpr as well. The rules for functions to qualify as constant expressions are very restrictive, but if you are able to build such an object, then global objects which are constant expressions may indeed be computed and stored at compile time. They count as being “statically initialized” (basically, initialized before program start-up).

    Prior to C++11, only the simplest primitive types were eligible for such treatment.

    Anything that requires dynamic allocation can never be a constant expression, so there’s no hope of having anything like a global std::map statically initialized.

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

Sidebar

Related Questions

Lets say I have an object that has stringProp1, stringProp2. I wish to store
Let's say i have a griffon object that needs to be part of the
For example lets say I have a JSON object that contains states and cities.
An interesting question arose today. Let's say I have a .NET object that implements
Lets say that you have a business object whose current state implies that there
Say I have a function func(i) that creates an object for an integer i,
In C#, suppose you have an object (say, myObject ) that is an instance
Lets say that I have one component which is doing something with Workbook object
Suppose I have a method that must return an object (say from a database
Let's say I have some model objects that resemble this: public class FooModel {

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.