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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:08:10+00:00 2026-05-29T22:08:10+00:00

Consider the following code (C++11), which uses the Eigen 3 library (http://eigen.tuxfamily.org): #include <iostream>

  • 0

Consider the following code (C++11), which uses the Eigen 3 library (http://eigen.tuxfamily.org):

#include <iostream>
#include <Eigen/Core>

template<typename T, int x, int y>
class mat {
        public:
        private:
                T data[x*y];
};

class bazinga {
        public:
                template<typename T>
                static void static_foo() {
                        std::cout << "STATIC BAZINGA FOO!\n";
                }

                template<typename T>
                void foo() {
                        std::cout << "BAZINGA FOO!\n";
                }
};

template<typename T>
void direct_foo() {
        std::cout << "JUST FOO-IN'!\n";
}

template<int i, int ... is>
void bar( bazinga &bz) {

        direct_foo<          mat<float, sizeof...(is), 3> >(); // OK
        bazinga::static_foo< mat<float, sizeof...(is), 3> >(); // OK
        bz.foo<              mat<float, sizeof...(is), 3> >(); // OK

        direct_foo<          Eigen::Matrix<float, sizeof...(is), 3> >(); // OK
        bazinga::static_foo< Eigen::Matrix<float, sizeof...(is), 3> >(); // ERROR
        bz.foo<              Eigen::Matrix<float, sizeof...(is), 3> >(); // ERROR

        bazinga::static_foo< Eigen::Matrix<float, 3, 3> >(); // OK!!!
        bz.foo<              Eigen::Matrix<float, 3, 3> >(); // OK!!!
}

int main() {
        bazinga bz;
        bar<1,2,3,4>(bz);
}

Class “mat” is just there to demonstrate that the errors do not occur using own classes, but only with the Eigen::Matrix class.

Can someone come up with a reason or clues on why this is happening? Or post a solution?

Thank you!

EDIT: i use g++ 4.6.1 on ubuntu 11.10
here is the compiler output:

main.cpp: In function ‘void bar(bazinga&) [with int i = 1, int ...is = {2, 3, 4}]’:
main.cpp:46:24:   instantiated from here
main.cpp:37:9: error: no matching function for call to ‘bazinga::static_foo()’
main.cpp:37:9: note: candidate is:
main.cpp:14:29: note: template<class T> static void bazinga::static_foo()
main.cpp:38:9: error: no matching function for call to ‘bazinga::foo()’
main.cpp:38:9: note: candidate is:
main.cpp:19:22: note: template<class T> void bazinga::foo()

EDIT2: I guess I was not clear enough: what surprises me most is that if i pass a fixed value as second template parameter (as in the last two lines of bar()) everything works fine, only using the sizeof…() operator results in errors, and only when used with Eigen::Matrix.

  • 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-29T22:08:11+00:00Added an answer on May 29, 2026 at 10:08 pm

    I think it is a compiler bug, as passing integral literal works fine, but sizeof...(is) doesn’t work. So I would suggest you to try this:

    constexpr int s = sizeof...(is);
    bazinga::static_foo< Eigen::Matrix<float, s, 3> >();
    bz.foo<              Eigen::Matrix<float, s, 3> >(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code which shows compile time error : #include <stdio.h> int main(int
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Consider following code: main.cpp: #include <iostream> typedef void ( * fncptr)(void); extern void externalfunc(void);
Consider the following sample code which uses a TrustManager to log whether an outgoing
Consider the following code which uses non-blocking semantics to pop a stack: T Stack<T>::pop(
Consider the following code, which uses two slightly different methods to check _instance and
Consider the following code which is typcial of many ChannelFactory examples: WSHttpBinding myBinding =
consider the following code, which represents an attempt to implement partial matching. the intended
Let's consider the following scenario: a function which can generate code colors from white
Consider the following code which is to be thrown at an AR find: conditions

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.