Giter VIP home page Giter VIP logo

uebungen_prgt_1718's People

Contributors

sydrimon avatar tartg avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

uebungen_prgt_1718's Issues

No implicit conversion from enum class EventType to int (MinGW)

Hello,
I'm having the problem to properly compile the code and receive the following error:

error: no match for call to '(const std::hash) (const EventType&)'

build with TDM-GCC-64 (x86_64-w64-mingw32) also tried with the normal mingw32 but still that error.

Made a minimalistic example of it:

#include <iostream>
#include <unordered_map>

enum class test{
	A,B,C,D,E,F
};

int main() {
	std::cout << "!!!Hello World!!!" << std::endl;
	std::unordered_map<test,int, std::hash<int> > m;
	m[test::A] = 12;

	std::cout << "m[test::A]:" << m[test::A] << std::endl;
	return 0;
}

and it still produces that error. I suspect that is has to do with the strong type of the enum class which does not have an implicit conversion to int. But unordered_map needs int for the hash function. unordered_map just knows about int and not about test or EventType (in this case).

also see:
https://stackoverflow.com/questions/8357240/how-to-automatically-convert-strongly-typed-enum-into-int
https://stackoverflow.com/questions/18837857/cant-use-enum-class-as-unordered-map-key

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.