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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:06:28+00:00 2026-05-27T01:06:28+00:00

I get this compile error (sorry, unimplemented: mangling overload) for a piece of code

  • 0

I get this compile error (sorry, unimplemented: mangling overload) for a piece of code that is, as far as I can tell, correct. I have tried to minimize the code to a manageable example, but it’s still quite long (sorry about that). I know the C++11 stuff in there are under development, so it might be a problem with my compiler (GCC 4.6.2), but it might also be me missing something.

The mod-functions are merely placeholders for more complex functions (with different return types). The purpose of the real code is to provide indices over a collection of data structures, to allow fast look-up using different matching criteria.

Cheers
Markus

#include <map>
#include <string>
#include <iostream>
#include <list>
#include <functional>
#include <cassert>

//
// Functions
//

struct mod2 : public std::unary_function<int, int> {
  int operator()(int x) const { return x % 2; }
};

struct mod3 : public std::unary_function<int, int> {
  int operator()(int x) const { return x % 3; }
};

struct mod4 : public std::unary_function<int, int> {
  int operator()(int x) const { return x % 4; }
};


//
// Base class foo
//

struct foo {
  std::vector<int> data_m;

  foo() : data_m() {}

  int& insert(int x) {
    data_m.push_back(x);
    return data_m.back();
  }

  template<typename trans_T>
  std::list<std::pair<typename trans_T::result_type, int> >
  match(const typename trans_T::result_type& pattern,
        const trans_T& trans = trans_T()) const {
    std::list<std::pair<typename trans_T::result_type, int> > results;
    for (auto it = data_m.begin(); it != data_m.end(); ++it) {
      auto p = trans(*it);
      if (pattern == p) {
        results.push_back(std::make_pair(p, *it));
      }
    }
    return results;
  }
};


//
// Derived class bar
//

template<typename base_T, typename trans_T>
struct bar : public base_T {
  typedef base_T base_type;
  typedef std::multimap<typename trans_T::result_type, int> index_type;
  index_type index_m;

  bar(const trans_T& trans = trans_T()) : base_type(), index_m() {}

  int& insert(int x, const trans_T& trans = trans_T()) {
    return index_m.insert(typename index_type::value_type(trans(x), base_type::insert(x)))->second;
  }

  std::pair<typename index_type::const_iterator,
            typename index_type::const_iterator>
  match(const typename trans_T::result_type& pattern,
        const trans_T& trans = trans_T()) const {
    return index_m.equal_range(pattern);
  }

  template<typename xtrans_T>
  decltype(base_type().match(typename xtrans_T::result_type(), xtrans_T()))
  match(const typename xtrans_T::result_type& pattern,
        const xtrans_T& xtrans = xtrans_T()) const {
    return base_type::match(pattern, xtrans);
  }

};


//
// Begin/end functions present in Boost but not in GCC
//

template<typename iter_T>
  iter_T begin(const std::pair<iter_T, iter_T>& range) {
  return range.first;
}

template<typename iter_T>
  iter_T end(const std::pair<iter_T, iter_T>& range) {
  return range.second;
}


//
// Main
//

int main(const int argc, const char** argv) {
  using std::cout;
  using std::endl;

  bar<bar<foo, mod2>, mod3> baz;


  ///
  /// Insert some numbers
  ///

  for (int i = 0; i < 20; ++i) {
    baz.insert(i);
  }

  for (int i = 0; i < 5; ++i) {
    cout << "i = " << i << endl;

    ///
    /// Try to match with different functions
    ///

    auto baz_match_mod2 = baz.match(i, mod2());
    cout << "mod2:";
    for (auto it = begin(baz_match_mod2); it != end(baz_match_mod2); ++it) {
      assert(it->first == i);
      cout << ' ' << it->second;
    }
    cout << endl;

    auto baz_match_mod3 = baz.match(i, mod3());
    cout << "mod3:";
    for (auto it = begin(baz_match_mod3); it != end(baz_match_mod3); ++it) {
      assert(it->first == i);
      cout << ' ' << it->second;
    }
    cout << endl;

    auto baz_match_mod4 = baz.match(i, mod4());
    cout << "mod4:";
    for (auto it = begin(baz_match_mod4); it != end(baz_match_mod4); ++it) {
      assert(it->first == i);
      cout << ' ' << it->second;
    }
    cout << endl;
  }

  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-27T01:06:29+00:00Added an answer on May 27, 2026 at 1:06 am

    GCC’s error messages only use the phrase “sorry, unimplemented” when the problem is with the compiler, not with your code — in this case, you are trying to make use of a C++11 feature that is not yet fully supported.

    Unfortunately, GCC’s website doesn’t let me grep the code for that particular error message, so I can’t help you figure out exactly what is not implemented. I second Basile’s recommendation to ask on gcc-help@gcc.gnu.org.

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

Sidebar

Related Questions

How can I get this to compile? The error is when I start using
I can't seem to compile ironruby in ruby 1.8.7. I always get this error:
I get an error when I compile this code: using System; public struct Vector2
I always get this error when trying to compile my file with Boost::GIL PNG
When I compile a project I get this error: C:\DATOSA~1\FAXENG~1>nmake /f Makefile.vc clean Microsoft
I get a compile error, which I'm slightly confused about. This is on VS2003.
hI, I'm trying to get this code from Larry Nyhoff's book to compile in
I get this error: Can't locate Foo.pm in @INC Is there an easier way
When I try and compile this program, I get errors (included below the code)
Why do I get compiler errors with this Java code? 1 public List<? extends

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.