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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:55:01+00:00 2026-05-20T14:55:01+00:00

I am trying to use templates recursively to define (at compile-time) a d-tuple of

  • 0

I am trying to use templates recursively to define (at compile-time) a d-tuple of doubles. The code below compiles fine with Visual Studio 2010, but g++ fails and complains that it “cannot call constructor ‘point<1>::point’ directly”.

Could anyone please shed some light on what is going on here?

Many thanks, Jo

#include <iostream>
#include <utility>

using namespace std;

template <const int N>
class point
{

private:
  pair<double, point<N-1> > coordPointPair;

public:

  point()
  {
    coordPointPair.first = 0;
    coordPointPair.second.point<N-1>::point();
  }

};

template<>
class point<1>
{

private:
  double coord;

public:

  point()
  {
    coord= 0;
  }

};

int main()
{
  point<5> myPoint;

  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-20T14:55:02+00:00Added an answer on May 20, 2026 at 2:55 pm

    What are you trying to do with:

    coordPointPair.second.point<N-1>::point();
    

    It looks like you want to explicitly call the point default constructor – which has already been called when the pair was constructed. You cannot call constructors directly (unless you use placement new, which wouldn’t make sense in this scenario)

    Just remove that line.

    If you for some reason want to overwrite the already constructed .second by assigning to it from a temporary point<N-1> you can do so with coordPointPair.second = point<N-1>();.

    If you, for a more complex case, want to pass arguments to a point constructor you can do this in the initializer list:

    point(your_type your_arg) : 
        coordPointPair(
            pair<double, point<N-1> >(0.0, point<N-1>(your_arg_here))
        )
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use templates along with vector in my code the following
I'm trying to use stl algorithm for_each without proliferating templates throughout my code. std::for_each
I'm trying to use templates to get std:list of items, where each item has
I'm trying to use the T4 templates in my MVC project. This screencast suggests
I am trying to accomplish a module where i need to use nested templates
As documented here: http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/ I am trying to use this function: ( function getTemplateAjax(path,
I'm trying to use templates with multiple to pass data onto a function, but
I'm new to node.js. I'm trying to use EJS templates, and i've got a
I am trying to use python for translating a set of templates to a
I'm trying to use this env variable to specify the path for my templates

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.