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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:12:55+00:00 2026-05-28T01:12:55+00:00

Im trying to find a way to tell if a type is a pointer

  • 0

I”m trying to find a way to tell if a type is a pointer at compile time. That is something like this:

#include <type_traits>
#if std::is_pointer<char*>::value
#pragma message("blah")
#endif

However, this gives “warning C4067: unexpected tokens following preprocessor directive – expected a newline” twice (I think the :: is what confuses it) and it doesn’t print blah. When I hoover over ::value the compiler tells me if it’s true, which means it’s known at compile time so this should work.

The reason for this is that I want to be able to do something like this:

T pHead;
#if std::is_pointer<T>::value
pHead= NULL;
#endif

where I NULL the variable if it’s a pointer. It has to be a compile time check because if T is a struct I cannot assign NULL to its variable. I.e. the following code won’t compile when T is a struct:

T pHead;
if (std::is_pointer<T>::value)
    pHead= NULL;

Thanks
Matt

  • 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-28T01:12:56+00:00Added an answer on May 28, 2026 at 1:12 am

    You can initialize the variable to its default value, which is NULL for a pointer type.

    T pHead = T();
    

    Works for most structs as well.

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

Sidebar

Related Questions

I am trying to find a way to determine at run-time how much memory
I'm trying to find a way to get the execution time of a section
I am trying to find a way in sencha touch store that when loading
I'm trying to find an elegant way to parse a string like: EVENT_TYPE(param1;param2; ...)
I'm desperately trying to find a way to make a custom UIAlertView that allows
I am trying to find a programmatic way to tell if a binary is
I'm trying to find a way to test my objective-c classes like i test
I am trying to find a way to animate two views in this way:
Trying to find a way to send a POST HTTPS request from Python to
I'm trying to find a way to list the (static) dependency requirements of a

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.