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 3305728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:12:15+00:00 2026-05-17T21:12:15+00:00

I have a string: B<T>::B() [with T = int] Is there any way I

  • 0

I have a string:
B<T>::B() [with T = int]

Is there any way I can get
B<T> [with T = int] from this before run time somehow? 🙂

Simplifying: Is there any way to get X & Y separately from a static string XY defined as a preprocessor macro in any form before runtime?

  • 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-17T21:12:15+00:00Added an answer on May 17, 2026 at 9:12 pm

    In current C++ I cannot think on a way to split the string at compile time. Most of the template tricks will not work on string literals. Now, I imagine that you want this to use in some sort of logging mechanism and you want to avoid the impact of performing the split at runtime in each method invocation. If that is the case, consider adding a function that will perform the operation and then in each function a static const std::string to hold the value. That string will be initialized only once in the first call to the function:

    #define DEFINE_LOG_NAME static const std::string _function_name( parse( __PRETTY_FUNCTION__ ) )
    #define LOG_NAME( level ) do { DEFINE_LOG_NAME; log( level, _function_name ); } while (0)
    std::string parse( std::string const & pretty ) {
       // split here, return value
    }
    template <typename T>
    struct B {
       B() {
          LOG_NAME( DEBUG );
       }
    };
    

    (I have not tested this, so you might need to fiddle with it)

    This will have some runtime impact, but only once for each function. Also note that this approach is not thread safe: if two threads simultaneously call a method that has not been called before there will be a race condition.

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

Sidebar

Related Questions

Have you ever tried this before? static void Main(string[] args) { int x =
I have a string coming from a table like can no pay{1},as your payment{2}due
I have a Dictionary<string,int> that has the potential to contain upwards of 10+ million
I have a method lets say: private static String drawCellValue( int maxCellLength, String cellValue,
If I have a method such as: public void MyMethod(int arg1, string arg2) How
I have two complex (i.e. objects with string, int, double, List and other home
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I have code to read in the version number from a make file. VERSION_ID=map(int,re.match(VERSION_ID\s*=\s*(\S+),open(version.mk).read()).group(1).split(.))
I have string that I want to chop to array of substrings of given

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.