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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:18:21+00:00 2026-05-26T19:18:21+00:00

In code (just paste and copy)is there a way to avoid repetition/listing of template

  • 0

In code (just paste and copy)is there a way to avoid repetition/listing of template args(line marked in code):

#include <iostream>

using namespace std;


template<class T,class... V>
struct nullptr_
{
    nullptr_(T& obj,V&... args)
    {
        nullptr_hlp(obj,args...);
    }

    template<class A>
    static void nullptr_hlp(A& a);
    {
        a = nullptr;
    }

    template<class A,class... Vs>
    static void nullptr_hlp(A& a,Vs&... args)
    {
        a = nullptr;
        nullptr_hlp(args...);
    }

};


class X : nullptr_<int*,double*,char*>//IS THERE A WAY TO HAVE JUST nullptr_?
{

    int* a;
    double* b;
    char* c;
    typedef nullptr_<decltype(a),decltype(b),decltype(c)> init_;
public:
    X():init_(a,b,c)
    {

    }

};
int main()
{
   X x;
    return 0;
}
  • 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-26T19:18:22+00:00Added an answer on May 26, 2026 at 7:18 pm

    nullptr_<int*,double*,char*> becomes an injected class name within X, so you can refer to it without the argument list:

    class X : nullptr_<int*,double*,char*>//can't do away with the list here, unless you want to typedef it
    {
    
        int* a;
        double* b;
        char* c;
        //typedef nullptr_<decltype(a),decltype(b),decltype(c)> init_; //don't really need this
    public:
        X():nullptr_(a,b,c) //can be used without the argument list
        {
    
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a question about copy/paste workflow in gVim. Right now I'm working on a
I find this code useful and want to copy-paste it into my application which
My code just scrapes a web page, then converts it to Unicode. html =
See code just bellow Our generic interface public interface Repository<INSTANCE_CLASS, INSTANCE_ID_CLASS> { void add(INSTANCE_CLASS
I'm writing some code (just for fun so far) in Python that will store
I'm someone who writes code just for fun and haven't really delved into it
I want to define some member variable and some code just in Debug Mode,
I'm trying to run a 3d array but the code just crashes in windows
I have made a new windows service which works fine using barebone code (just
Help, please. The code - just a styled pre and a styled div (using

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.