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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:30:59+00:00 2026-05-14T01:30:59+00:00

I am trying to use elements of meta programming, but hit the wall with

  • 0

I am trying to use elements of meta programming, but hit the wall with the first trial.
I would like to have a comparator structure which can be used as following:

intersect_by<ID>(L1.data, L2.data, "By ID: ");
intersect_by<IDf>(L1.data, L2.data, "By IDf: ");

Where:

  struct ID{};// Tag used for original IDs
    struct IDf{};// Tag used for the file position  
    //following Boost.MultiIndex examples  
    template<typename Tag,typename MultiIndexContainer>
    void intersect_by(
    const MultiIndexContainer& L1,const MultiIndexContainer&    L2,std::string msg,
      Tag* =0 /* fixes a MSVC++ 6.0 bug with implicit template function parms */
    )
    {
     /* obtain a reference to the index tagged by Tag */

     const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& L1_ID_index=
     get<Tag>(L1);
     const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& L2_ID_index=
     get<Tag>(L2);

      std::set_intersection(
      L1_ID_index.begin(), 
      L1_ID_index.end(), 
      L2_ID_index.begin(), 
      L2_ID_index.end(),
      std::inserter(s, s.begin()), strComparator<Tag>() // Here I get the C2975 error
      );
      }

    template<int N> struct strComparator;
    template<> 
    struct strComparator<0>{
    bool operator () (const particleID& id1, const particleID& id2) const
    {
     return id1.ID<id2.ID;
    }
    };
    template<> 
    struct strComparator<1>{ 
    bool operator () (const particleID& id1, const particleID& id2) const
    {
     return id1.IDf<id2.IDf; 
    }

    };

What I am missing?

kind regards
Arman.

Sorry I did not copy the full error message.
Full error:

>Compiling...
1>trace_ids.cpp
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2975: 'strComparator' : invalid template argument for 'N', expected compile-time constant expression
1>        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
1>        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(144) : see reference to function template instantiation 'void intersect_by<ID,particlesID_set>(const MultiIndexContainer &,const MultiIndexContainer &,std::string,Tag *)' being compiled
1>        with
1>        [
1>            MultiIndexContainer=particlesID_set,
1>            Tag=ID
1>        ]
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2955: 'strComparator' : use of class template requires template argument list
1>        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2784: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&)[_Size],_Pr)' : could not deduce template argument for '_OutElem (&)[_Size]' from 'std::insert_iterator<_Container>'
1>        with
1>        [
1>            _Container=particlesID_set
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4064) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if<!std::_Is_checked_iterator<_OutIt>::_Result,_OutIt>::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4004) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&)[_Size])' : expects 5 arguments - 6 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3993) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if<std::_Is_checked_iterator<_OutIt>::_Result,_OutIt>::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3983) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2975: 'strComparator' : invalid template argument for 'N', expected compile-time constant expression
1>        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
1>        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(146) : see reference to function template instantiation 'void intersect_by<IDf,particlesID_set>(const MultiIndexContainer &,const MultiIndexContainer &,std::string,Tag *)' being compiled
1>        with
1>        [
1>            MultiIndexContainer=particlesID_set,
1>            Tag=IDf
1>        ]
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(133) : error C2955: 'strComparator' : use of class template requires template argument list
1>        c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(47) : see declaration of 'strComparator'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2784: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&)[_Size],_Pr)' : could not deduce template argument for '_OutElem (&)[_Size]' from 'std::insert_iterator<_Container>'
1>        with
1>        [
1>            _Container=particlesID_set
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4064) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if<!std::_Is_checked_iterator<_OutIt>::_Result,_OutIt>::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(4004) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '_OutElem *std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutElem (&)[_Size])' : expects 5 arguments - 6 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3993) : see declaration of 'std::set_intersection'
1>c:\documents and settings\arm2arm\mes documents\visual studio 2008\projects\mstgraph\trace_ids\trace_ids.cpp(134) : error C2780: '::std::_Enable_if<std::_Is_checked_iterator<_OutIt>::_Result,_OutIt>::_Result std::set_intersection(_InIt1,_InIt1,_InIt2,_InIt2,_OutIt)' : expects 5 arguments - 6 provided
1>        c:\program files\microsoft visual studio 9.0\vc\include\algorithm(3983) : see declaration of 'std::set_intersection'
1>Build log was saved at "file://c:\Documents and Settings\arm2arm\Mes documents\Visual Studio 2008\Projects\mstgraph\trace_ids\Debug\BuildLog.htm"
1>trace_ids - 12 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 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-14T01:30:59+00:00Added an answer on May 14, 2026 at 1:30 am

    I suspect that instead of

    template<int N> struct strComparator;
    

    you want

    template<typename T> struct strComparator;
    
    template <> struct strComparator<Id>{...}; //etc
    
    • 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 jquery's parents/siblings to find particular input elements but I
I am trying to learn and use html5 and have a basic layout but
I am trying to use the on method for future DOM elements, but for
I'm trying to use XPath to find all elements that have an element in
I am trying to use JavaScript to set an elements width relative to their
I am trying to use jQuery's draggable and sortable to sort elements listed inside
I am trying to use css3's :not() selector to select certain elements that do
I'm trying to use the getElementsByTagName(a) method to get all the elements under a
I am trying to use selenium.getEval() to get all of the elements with a
I'm currently struggling to use UI elements in Interface Builder. I keep trying to

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.