Conversion Error from 'unsigned __int64' to 'unsigned __int64 *' - Pybind11 - c++

After downloading this https://github.com/pybind/pybind11/archive/v2.2.3.zip
and creating a simple cpp file:
#include <pybind11/pybind11.h>
int add(int i, int j) { return i + j; }
PYBIND11_MODULE(example, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &add, "A function which adds two numbers");
}
with
I get this error
Error C2446 '<': no conversion from 'unsigned __int64' to 'unsigned __int64 *' in c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector line 2326
Would anybody know what this could be referring to, and possibly how to fix it?
As requested, here the full error log:
1>------ Rebuild All started: Project: Test_CreatePythonBindings, Configuration: Debug x64 ------
1>example.cpp
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2326): error C2446: '<': no conversion from 'unsigned __int64' to 'unsigned __int64 *'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2326): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2325): note: while compiling class template member function 'std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>> &std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>::operator +=(__int64)'
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2545): note: see reference to function template instantiation 'std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>> &std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>::operator +=(__int64)' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2490): note: see reference to class template instantiation 'std::_Vb_const_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(3094): note: see reference to class template instantiation 'std::_Vb_iterator<std::_Wrap_alloc<std::allocator<std::_Vbase>>>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(3093): note: while compiling class template member function 'void std::vector<bool,std::allocator<_Ty>>::push_back(const bool &)'
1> with
1> [
1> _Ty=bool
1> ]
1>c:\pybind11-2.2.3\include\pybind11\pybind11.h(513): note: see reference to function template instantiation 'void std::vector<bool,std::allocator<_Ty>>::push_back(const bool &)' being compiled
1> with
1> [
1> _Ty=bool
1> ]
1>c:\pybind11-2.2.3\include\pybind11\cast.h(1806): note: see reference to class template instantiation 'std::vector<bool,std::allocator<_Ty>>' being compiled
1> with
1> [
1> _Ty=bool
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\vector(2326): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
1>Done building project "Test_CreatePythonBindings.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

It appears to be a VS 2017 issue related to
std::vector<bool>
Separate question asked here:
Pushback on vector<bool> fails - VS 2017

Related

Having trouble making a thread for a member function with parameters | C++ | WxWidgets

My thread gives me no errors before compilation, but upon compilation, I get this error...
Error code:
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(55,14): error C2672: 'invoke': no matching overloaded function found
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(62): message : see reference to function template instantiation 'unsigned int std::thread::_Invoke<_Tuple,0,1,2,3,4>(void *) noexcept' being compiled
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(66): message : see reference to function template instantiation 'unsigned int (__cdecl *std::thread::_Get_invoke<_Tuple,0,1,2,3,4>(std::integer_sequence<size_t,0,1,2,3,4>) noexcept)(void *) noexcept' being compiled
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(89): message : see reference to function template instantiation 'void std::thread::_Start<_Ty,std::vector<std::string,std::allocator<std::string>>&,std::vector<std::string,std::allocator<std::string>>&,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>&,std::vector<std::string,std::allocator<std::string>>&>(_Fn &&,std::vector<std::string,std::allocator<std::string>> &,std::vector<std::string,std::allocator<std::string>> &,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>> &,std::vector<std::string,std::allocator<std::string>> &)' being compiled
1> with
1> [
1> _Ty=void (__cdecl MyFrame::* )(std::vector<std::string,std::allocator<std::string>>,std::vector<std::string,std::allocator<std::string>>,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>,std::vector<std::string,std::allocator<std::string>>),
1> _Fn=void (__cdecl MyFrame::* )(std::vector<std::string,std::allocator<std::string>>,std::vector<std::string,std::allocator<std::string>>,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>,std::vector<std::string,std::allocator<std::string>>)
1> ]
1>C:\Users\Me\C++\Data-Mange-Bot-C++ver\DataManageApp\main.cpp(2578): message : see reference to function template instantiation 'std::thread::thread<void(__cdecl MyFrame::* )(std::vector<std::string,std::allocator<std::string>>,std::vector<std::string,std::allocator<std::string>>,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>,std::vector<std::string,std::allocator<std::string>>),std::vector<std::string,std::allocator<std::string>>&,std::vector<std::string,std::allocator<std::string>>&,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>&,std::vector<std::string,std::allocator<std::string>>&,0>(_Fn &&,std::vector<std::string,std::allocator<std::string>> &,std::vector<std::string,std::allocator<std::string>> &,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>> &,std::vector<std::string,std::allocator<std::string>> &)' being compiled
1> with
1> [
1> _Fn=void (__cdecl MyFrame::* )(std::vector<std::string,std::allocator<std::string>>,std::vector<std::string,std::allocator<std::string>>,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>,std::vector<std::string,std::allocator<std::string>>)
1> ]
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(51,5): error C2893: Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\type_traits(1482): message : see declaration of 'std::invoke'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(51,5): message : With the following template arguments:
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(51,5): message : '_Callable=void (__cdecl MyFrame::* )(std::vector<std::string,std::allocator<std::string>>,std::vector<std::string,std::allocator<std::string>>,std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>,std::vector<std::string,std::allocator<std::string>>)'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(51,5): message : '_Ty1=std::vector<std::string,std::allocator<std::string>>'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(51,5): message : '_Types2={std::vector<std::string,std::allocator<std::string>>, std::vector<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>,std::allocator<std::variant<std::string,std::vector<std::string,std::allocator<std::string>>>>>, std::vector<std::string,std::allocator<std::string>>}'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\thread(51,5): error C2780: 'unknown-type std::invoke(_Callable &&) noexcept(<expr>)': expects 1 arguments - 5 provided
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\type_traits(1476): message : see declaration of 'std::invoke'
This is despite following the solution provided in this question. Although the difference here is that I have multiple parameters and I'm starting the thread inside another member function.
I've looked at online resources and haven't turned up anything, if anyone can help that would be great.
Code:
class MyFrame : public wxFrame{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
void RightSearchBarTextChange(wxCommandEvent& event);
void RightSearchResultsCreate(std::vector<std::string> CategoryFilterMap, std::vector<std::string> SubCategoryFilterMap, std::vector<std::variant<std::string, std::vector<std::string>>> DateFilterMap, std::vector<std::string> TagFilterMap);
}
void MyFrame::RightSearchBarTextChange(wxCommandEvent& event) {
std::thread thread_object(&MyFrame::RightSearchResultsCreate, RightSearchCategoryFilterSelectedVector, RightSearchSubCategoryFilterSelectedVector, RightSearchDateFilterSelectedVector, RightSearchTagFilterSelectedVector);
thread_object.join();
}
void MyFrame::RightSearchResultsCreate(std::vector<std::string> CategoryFilterMap, std::vector<std::string> SubCategoryFilterMap, std::vector<std::variant<std::string, std::vector<std::string>>> DateFilterMap, std::vector<std::string> TagFilterMap) {
// do stuff here
}

Compiler Error occurs (Intel Parallel Studio 2020 19.1 with Visual Studio Community 2019)

I have a very simple example
#include
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
If I compile this with Visual Studio Compiler on Visual Studio Community 2019, then it works as expected.
However, when I change the compiler to Intel C++, installed with Intel Parallel Studio 2020(19.1), it returns an error
1>------ Build started: Project: Project1, Configuration: Debug x64 ------
1>Source.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(92): error : expected an identifier
1> !_Is_implicitly_default_constructible<_Uty1>::value || !_Is_implicitly_default_constructible<_Uty2>::value)
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(91): error : not a valid member class or function template declaration
1> constexpr explicit(
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(91): error : "explicit" is not allowed
1> constexpr explicit(
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(93): error : expected a ";"
1> pair() noexcept(
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(175): error : expected an identifier
1> constexpr explicit(!is_convertible<const _Other1&, _Ty1>::value // TRANSITION, VSO#946746
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(175): error : not a valid member class or function template declaration
1> constexpr explicit(!is_convertible<const _Other1&, _Ty1>::value // TRANSITION, VSO#946746
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(175): error : "explicit" is not allowed
1> constexpr explicit(!is_convertible<const _Other1&, _Ty1>::value // TRANSITION, VSO#946746
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(177): error : expected a ";"
1> pair(const pair<_Other1, _Other2>& _Right) noexcept(is_nothrow_constructible_v<_Ty1, const _Other1&>&&
1> ^
1>
1>compilation aborted for Source.cpp (code 2)
1>Done building project "Project1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If I comment out the #include and std::cout ~~, which is basically an empty program, then it compiles successfully and runs without error.
My system is
OS: 64bit Windows 10 Enterprise

Compiler Error (Intel Parallel Studio 2019 with Visual Studio Community 2019)

I have a very simple example
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
If I compile this with Visual Studio Compiler on Visual Studio Community 2019, then it works as expected.
However, when I change the compiler to Intel C++, installed with Intel Parallel Studio 2019, it returns an error
1>------ Build started: Project: Project1, Configuration: Debug x64 ------
1>Source.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(92): error : expected an identifier
1> !_Is_implicitly_default_constructible<_Uty1>::value || !_Is_implicitly_default_constructible<_Uty2>::value)
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(91): error : not a valid member class or function template declaration
1> constexpr explicit(
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(91): error : "explicit" is not allowed
1> constexpr explicit(
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(93): error : expected a ";"
1> pair() noexcept(
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(175): error : expected an identifier
1> constexpr explicit(!is_convertible<const _Other1&, _Ty1>::value // TRANSITION, VSO#946746
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(175): error : not a valid member class or function template declaration
1> constexpr explicit(!is_convertible<const _Other1&, _Ty1>::value // TRANSITION, VSO#946746
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(175): error : "explicit" is not allowed
1> constexpr explicit(!is_convertible<const _Other1&, _Ty1>::value // TRANSITION, VSO#946746
1> ^
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\utility(177): error : expected a ";"
1> pair(const pair<_Other1, _Other2>& _Right) noexcept(is_nothrow_constructible_v<_Ty1, const _Other1&>&&
1> ^
1>
1>compilation aborted for Source.cpp (code 2)
1>Done building project "Project1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If I comment out the #include <iostream> and std::cout ~~, which is basically an empty program, then it compiles successfully and runs without error.
My system is
OS: 64bit Windows 10 Enterprise
CPU: AMD Ryzen Threadripper 3970X
I had a similar compiling erro:
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\concepts(47): error : expected ';', near '{'
If I Disable the "bullseye coverage 8.9.44" (compatible til VS 2015) my prog compile with success.

With VC 15.4.0, std::function assignment produces C2679 (compiled with 15.3.5)

The following code compiles just fine with VC 15.3.5:
#include <Windows.h>
#include <string>
#include <memory>
#include <optional>
#include <functional>
class TypeDictionary;
class IStructureField {};
using FieldFactory = std::function<std::unique_ptr<IStructureField>(TypeDictionary& dict, LPCSTR szName, std::optional<ULONG> ulOffset, std::optional<std::string> strFieldType, std::optional<ULONG> ulFieldSize)>;
int main()
{
FieldFactory ff;
ff = [](TypeDictionary& dict, LPCSTR szName, std::optional<ULONG> ulOffset, std::optional<std::string> szFieldType, std::optional<ULONG> ulFieldSize) -> std::unique_ptr<IStructureField> {
return std::unique_ptr<IStructureField>();
};
return 0;
}
It produces the following error message with 15.4.0:
1>f:\projects\fullpath\fullpath\fullpath.cpp(22): error C2679: binary '=': no operator found which takes a right-hand operand of type 'main::<lambda_36489dce1cc59e5a8de4329a29806b5a>' (or there is no acceptable conversion)
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.11.25503\include\functional(656): note: could be 'std::function<std::unique_ptr<IStructureField,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)> &std::function<std::unique_ptr<_Ty,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)>::operator =(std::nullptr_t) noexcept'
1> with
1> [
1> _Ty=IStructureField
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.11.25503\include\functional(629): note: or 'std::function<std::unique_ptr<IStructureField,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)> &std::function<std::unique_ptr<_Ty,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)>::operator =(std::function<std::unique_ptr<_Ty,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)> &&)'
1> with
1> [
1> _Ty=IStructureField
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.11.25503\include\functional(612): note: or 'std::function<std::unique_ptr<IStructureField,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)> &std::function<std::unique_ptr<_Ty,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)>::operator =(const std::function<std::unique_ptr<_Ty,std::default_delete<_Ty>> (TypeDictionary &,LPCSTR,std::optional<ULONG>,std::optional<std::string>,std::optional<ULONG>)> &)'
1> with
1> [
1> _Ty=IStructureField
1> ]
1>f:\projects\fullpath\fullpath\fullpath.cpp(22): note: while trying to match the argument list '(FieldFactory, main::<lambda_36489dce1cc59e5a8de4329a29806b5a>)'
1>Done building project "FullPath.vcxproj" -- FAILED.
As I saw on cppcon (Stephan's talk), a lot of work has been done on <functional>... Could this be related? Any mistake I made?
Workarounds would be fine too.
Edit1: Added the two include files to help understand the issue is not there: Same error...
Edit2: After I repaired my VS installation, the code just compiled. However, the original code did not. I had bumped in https://developercommunity.visualstudio.com/content/problem/74313/compiler-error-in-xsmf-control-with-stdoptional-pa.html before and attempted the workaround (which exposed the issue I faced). Without the workaround, the code compiles (but hits the __this issue again...).

What's wrong with map?

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <iterator>
using namespace std;
int main()
{
map<char*, int> m;
int N;
scanf ("%d", &N);
for (int i = 0; i < N; i++)
{
char name[256], s[256];
scanf ("%s", &name);
gets (s);
m[name]++;
}
map<char*, int>::iterator itr;
for (itr = m.begin(); itr != m.end(); itr++)
printf ("%s %d", itr->first, (itr)->second);
}
This program meant to read number of lines then lines, and then output the number of times each word has been repeated in start of lines
for example with this input:
3
Spain Donna Elvira
England Jane Doe
Spain Donna Anna
I expect :
England 1
Spain 2
but I receive :
Spain 3
and I'm sure the the variable name is what it should be each time but something is wrong with the map.
my build log when I changed it to std::string
1>------ Build started: Project: UVa, Configuration: Debug Win32 ------
1> UVa.cpp
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(2245) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(179) : while compiling class template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const'
1> with
1> [
1> _Ty=std::string
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\map(194) : see reference to function template instantiation 'bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const' being compiled
1> with
1> [
1> _Ty=std::string
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\type_traits(743) : see reference to class template instantiation 'std::less<_Ty>' being compiled
1> with
1> [
1> _Ty=std::string
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(1028) : see reference to class template instantiation 'std::is_empty<_Ty>' being compiled
1> with
1> [
1> _Ty=std::less<std::string>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\map(67) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
1> with
1> [
1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
1> ]
1> c:\users\amiraz\documents\visual studio 2012\projects\uva\uva\uva.cpp(13) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
1> with
1> [
1> _Kty=std::string,
1> _Ty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(2245) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(2245) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtree(2245) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::move_iterator<_RanIt> &' from 'const std::string'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1983) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1983) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1983) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1983) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1259) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1259) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1259) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1259) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::string'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1075) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1075) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1075) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xutility(1075) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(232) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(232) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(232) : see declaration of 'std::operator <'
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(232) : see declaration of 'std::operator <'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef(180): error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
char* are compared as pointers, not as strings. Use std::string instead.
And as P0W mentioned,scanf, printf, gets are C-style. Maps and iterators are C++-style. Don't mix them. Use std::cin, std::cout, std::getline for IO in C++.
If you map with a char* as a key, you're really mapping the with the address of the string, not the string itself as a key. Since your buffer is identically allocated on the stack every time, it will most likely end up at the same address and map to the same value, no matter the content.
Mapping from std::string, the C++ alternative to C strings, will instead automatically use the content of the string as a key.