template < class Key, // unordered_map::key_type class T, // unordered_map::mapped_type |
Container properties |
1>c:\users\michael\documents\visual studio 2015\projects\test\test\test.cpp(12): error C2679: binary '<<': no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion) |
template < class Key, // unordered_map::key_type class T, // unordered_map::mapped_type class Hash = hash<Key>, // unordered_map::hasher class Pred = equal_to<Key>, // unordered_map::key_equal class Alloc = allocator< pair<const Key,T> > // unordered_map::allocator_type > class unordered_map; |
std::unordered_map<>
referring to what is between the <>s.When I use VS2015 and type in a cpp std::unordered_map<std::int a menu pop up and offers int16_t, int32_t, int64_t, and int8_t (and few other entries) -- but I have no clue why there is an "_t" attached to these integer types. And - ...! - where should I have found it within the Reference of this site. |
Container properties followed by five types, Associative, Unordered, Map, Unique keys, and Allocator-aware. But where do I find how to specify one of them? |
binary '<<': no operator found which takes a right-hand operand of type 'const std::string'
The first thing I notice is '<<'
. Over time I have learned to go to the top of the file to the "#includes" and make sure I have included "string"Sure, you may observe a lot by watching. But I want to go my own way instead of prying what others did. |
The hard part to understand is that "key and value" can be any valid variable type. |
... it explains each parameter. May be not well, but in time it will make more sense. |
In the section "Member types" the table can be very useful. The first two rows of the table cover what you are using now and of that "type" is the most important part meaning any valid variable type. |
The list box is Microsoft's way of trying to be helpful. Most of the time it is useful other times it is just annoying. |
Without seeing the actual line of code that goes with this error message It is hard to say what caused this. |
|
|
1>c:\users\...\documents\visual studio 2015\projects\test\test\test.cpp(2924): error C2679: binary '=': no operator found which takes a right-hand operand of type 'initializer list' (or there is no acceptable conversion) |
1>c:\users\...\documents\visual studio 2015\projects\test\test\test.cpp(2937): error C2679: binary '<<': no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion) |
Over time I have learned to go to the top of the file to the "#includes" and make sure I have included "string" |
This should answer some and bring more questions. Let me know what you do not understand. |
the VS2015 compiler |
std::random_shuffle
. I try to compile the code using C++17 and it goes down in flames. std::random_shuffle
was deprecated in C++14 and removed in C++17.std::shuffle
then. But wait, std::shuffle
doesn't use C's rand()
, it requires one of <random>
's PRNG engines.<chrono>
's std::system_clock
, not C's srand()
.for
loops or a container's begin()
/end()
iterators, is for me a nice way to reinforce the features.
It is fun watching code that compiled fine with older compilers suddenly go *BOOM* when a newer language standard is set. |
Book (source) code might use std::random_shuffle . I try to compile the code using C++17 and it goes down in flames. std::random_shuffle was deprecated in C++14 and removed in C++17. |
std::random_shuffle
is not valid in C++17. The function was removed from C++17. Compile as C++17 (or later) and any use of std::random_shuffle
now generates an error.std::random_shuffle
is deprecated. It shouldn't be used. The use will still compile.MikeStgt wrote: |
---|
My next step -- I do get rid of VS2015. Fatal error c1060, the compiler is out of heap space for just few lines of simple code is an unmistakably hint: get rid of it. |
What does it do with the small section of code you posted here? |
VS Community is indeed free. No money out of your pocket. |
I shall tell my first name, my last name, daymonthyear of birth, my nationality, and my e-mail address or my phone number. That's too much. |
you don't seem to give things much of a chance. |
bogus personal data |