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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:33:08+00:00 2026-05-11T09:33:08+00:00

How do I allow the STL implementation to pick up my custom types? On

  • 0

How do I allow the STL implementation to pick up my custom types? On MSVC, there is a class std::tr1::hash, which I can partially specialize by using

namespace std  {     namespace tr1      {          template <>          struct hash<MyType>          { ... };     }  } 

but is this the recommended way? Moreover, does this work with GCC’s implementation as well? For boost::hash, it’s enough to provide a free function size_t hash_value (const MyType&), is there something similar for the TR1 implementation?

  • 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. 2026-05-11T09:33:08+00:00Added an answer on May 11, 2026 at 9:33 am

    Yes, this will also work for GCC. I’m using it in a bigger project and it works without problems. You could also provide your own custom hashing class for the TR1 containers, but it is specified that std::tr1::hash<> is the default hashing class. Specializing it for custom types seems like the natural way to extend the standard hashing functionality.

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

Sidebar

Related Questions

how can I create STL collection of classes which implement abstract base class using
I'm trying to write a class which contains several std::vectors as data members, and
Do anyone know if there is a STL interface compatible string class that allocates
I have a stl::map which key type is a custom struct. I want to
C# and Java allow almost any character in class names, method names, local variables,
How can you allow a PHP script to write to a file with high-security
For instance why does most members in STL implementation have _M_ or _ or
I have a DLL which needs to access data stored in STL containers in
Duplicate: Choosing a STL container with uniqueness and which keeps insertion ordering I'm looking
Here's a fairly normal encapsulation of an STL container which allows the user of

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.