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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:15:16+00:00 2026-06-18T15:15:16+00:00

I’m receiving a compiler error /Developer/boost/boost/numeric/ublas/expression_types.hpp:184:16: fatal error: recursive template instantiation exceeded maximum depth

  • 0

I’m receiving a compiler error

/Developer/boost/boost/numeric/ublas/expression_types.hpp:184:16: fatal error: recursive template instantiation exceeded maximum depth of 512

from clang++ or indefinite compiling with >10GB memory usage from g++ 4.2.1.

I’m trying to create a helper function that subtracts a scalar from each element of a vector. Thinking generically at first, I planned to have the specific vector storage type a template parameter. That being said, I’m realizing I don’t know how to make the definition work for both ublas and std vectors at this point (without specialization). But I’m still wondering what is happening / the reason for my compile troubles?

The problem is readily demonstrated with the below code when complied with the boost library, e.g.
g++ -I/path/boost bug_demo.cpp

Is there a bug in boost or in my code?

// demo code does not compiler, instead error for recursive template instantiation
//---------------------------------------------------------

#include <boost/numeric/ublas/vector.hpp>

namespace ublas = boost::numeric::ublas; // boost ublas will be the implementation for basic vector container
typedef ublas::vector<double>  DVEC; // double vector shorthand

// ********* problem function  ***********
template <typename vec_t, typename scalar_t>
vec_t operator-( const vec_t & vec, scalar_t scalar )
{
    ublas::scalar_vector<scalar_t> scalar_v(vec.size(), scalar);
    return vec - scalar_v;
}

// this non-template version works fine.
/*  DVEC operator-( const DVEC & vec, double scalar )
{
    ublas::scalar_vector<double> scalar_v(vec.size(), scalar);
    return vec - scalar_v;
}
*/

DVEC vectorFunc( const DVEC& x )
{
    double bnew=0.0;
    DVEC x_bnew;
    x_bnew = operator-(x,bnew);
    return x_bnew;
}

int main()
{
    DVEC inputVector(2);
    inputVector[0] = 1.0; inputVector[1] = 2.0;

    DVEC output = vectorFunc( inputVector );
    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-06-18T15:15:18+00:00Added an answer on June 18, 2026 at 3:15 pm

    Your operator - () function is setting up an infinite template instantiation recursion by invoking itself when doing vec - scalar_v. Although the name of the parameter type is scalar_t, this is just a name and it can match any type, including a scalar_vector<scalar_t>.

    Thus, the line xbnew = operator - (x, bnew) will cause the instantiation of:

    operator - <DVEC, double>()
    

    The last line in that operator template will in turn cause the instantiation of:

    operator - <DVEC, scalar_vector<double>>()
    

    Then, the last line in the same operator template will cause the instantiation of:

    operator - <DVEC, scalar_vector<scalar_vector<double>>>()
    

    And so on until the compiler reaches the maximum instantiation recursion depth.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.