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

The Archive Base Latest Questions

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

I know how to write something up but i am sure there is a

  • 0

I know how to write something up but i am sure there is a standard way of passing in something like func<TheType*>() and using template magic to extract TheType for use in your code (maybe TheType::SomeStaticCall).

What is the standard way/function to get that type when a ptr is passed in?

  • 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-23T00:23:40+00:00Added an answer on May 23, 2026 at 12:23 am

    I think you want to remove the pointer-ness from the type argument to the function. If so, then here is how you can do this,

    template<typename T>
    void func()
    {
        typename remove_pointer<T>::type type;
        //you can use `type` which is free from pointer-ness
    
        //if T = int*, then type = int
        //if T = int****, then type = int 
        //if T = vector<int>, then type = vector<int>
        //if T = vector<int>*, then type = vector<int>
        //if T = vector<int>**, then type = vector<int>
        //that is, type is always free from pointer-ness
    }
    

    where remove_pointer is defined as:

    template<typename T>
    struct remove_pointer
    {
        typedef T type;
    };
    
    template<typename T>
    struct remove_pointer<T*>
    {
        typedef typename remove_pointer<T>::type type;
    };
    

    In C++0x, remove_pointer is defined in <type_traits> header file. But in C++03, you’ve to define it yourself.

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

Sidebar

Related Questions

As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
I know I could write scripts and create jobs to run them, but at
I know how to write the basic c# code to send emails, but I'm
So I know I can write my own HTML-encoding function like this: function getHTMLEncode(t)
Is there a way in handlebars JS to incorporate logical operators into the standard
I'm sure there is a correct way to do this, I'm new to objective-c
I should probably know this already, but I'm not sure and I don't see
Calling all C macro gurus... Is there any way to write a C macro
I'd like to write data to NFC tags such that I know that when
Im sure there are a thousand different posts on Maple vs Matlab, but i

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.