Upon writing include for the QtSql library into the code, any attempt at compilation returns "no match for operator". Deleting/commenting out the line with "include" gets rid of the errors.
The exact errors that occur are:
no match for 'operator==' (operand types are 'std::thread::native_handle_type{aka ptw32_handle_t}' and 'std::thread::native_handle_type{aka ptw32_handle_t}')
no match for 'operator<' (operand types are 'std::thread::native_handle_type{aka ptw32_handle_t}' and 'std::thread::native_handle_type{aka ptw32_handle_t}')
The files in my project:
Upload.pro
QT += core
QT -= gui
QT += sql
CONFIG += c++11
TARGET = Upload
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
unix|win32: LIBS += -L'C:/Program Files/PostgreSQL/9.5/lib/' -llibpq
INCLUDEPATH += 'C:/Program Files/PostgreSQL/9.5/include'
DEPENDPATH += 'C:/Program Files/PostgreSQL/9.5/include'
main.cpp
#include <QCoreApplication>
#include <QFile>
#include <QDebug>
#include <QTextStream>
#include <QtSql>
#include <QSqlQuery>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return 0;
}
I am using QT 5.12.0 with QT Creator 4.8.0 (MinGW 7.3.0 64 bit is set as compiler).
The program was installed with an offline installer, so it's not custom-built, which is why I'm hesitant to consider it a bug in program itself. Searching for similar issues also didn't give me any results.
I have previously solved similar sql-related programming problems using an earlier version of QT on a 32-bit computer, so I'm almost sure the code is fine as well.
Is this an issue with compiler settings? Or is that some complication in a newer version of QT?
EDIT: A fragment of the error message
EDIT 2: A fragment of error log (full error log is 226k+ characters long, which exceeds post limit)
14:13:47: Running steps for project Upload...
14:13:47: Configuration unchanged, skipping qmake step.
14:13:47: Starting: "C:\Qt\Qt5.12.0\Tools\mingw730_64\bin\mingw32-make.exe" -j8
C:/Qt/Qt5.12.0/Tools/mingw730_64/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'E:/User/databasePrograms/build-Upload-Desktop_Qt_5_12_0_MinGW_64_bit-Debug'
g++ -c -fno-keep-inline-dllexport -g -std=gnu++11 -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_SQL_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\Upload -I. -I"C:\Program Files\PostgreSQL\9.5\include" -IC:\Qt\Qt5.12.0\5.12.0\mingw73_64\include -IC:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql -IC:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtCore -Idebug -IC:\Qt\Qt5.12.0\5.12.0\mingw73_64\mkspecs\win32-g++ -o debug\main.o ..\Upload\main.cpp
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread: In function 'bool std::operator==(std::thread::id, std::thread::id)':
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:26: error: no match for 'operator==' (operand types are 'std::thread::native_handle_type {aka ptw32_handle_t}' and 'std::thread::native_handle_type {aka ptw32_handle_t}')
return __x._M_thread == __y._M_thread;
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:270:3: note: candidate: bool std::operator==(std::thread::id, std::thread::id)
operator==(thread::id __x, thread::id __y) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:270:3: note: no known conversion for argument 1 from 'std::thread::native_handle_type {aka ptw32_handle_t}' to 'std::thread::id'
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:81:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:378:5: note: candidate: template<class _Tp> bool std::operator==(std::nullptr_t, const std::shared_ptr<_Tp>&)
operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:378:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::shared_ptr<_Tp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:81:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:373:5: note: candidate: template<class _Tp> bool std::operator==(const std::shared_ptr<_Tp>&, std::nullptr_t)
operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:373:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::shared_ptr<_Tp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:81:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:368:5: note: candidate: template<class _Tp, class _Up> bool std::operator==(const std::shared_ptr<_Tp>&, const std::shared_ptr<_Up>&)
operator==(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:368:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::shared_ptr<_Tp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:52:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:81,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr_base.h:1420:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator==(std::nullptr_t, const std::__shared_ptr<_Tp, _Lp>&)
operator==(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr_base.h:1420:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::__shared_ptr<_Tp, _Lp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:52:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:81,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr_base.h:1415:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator==(const std::__shared_ptr<_Tp, _Lp>&, std::nullptr_t)
operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr_base.h:1415:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::__shared_ptr<_Tp, _Lp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr.h:52:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:81,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr_base.h:1409:5: note: candidate: template<class _Tp1, class _Tp2, __gnu_cxx::_Lock_policy _Lp> bool std::operator==(const std::__shared_ptr<_Tp1, _Lp>&, const std::__shared_ptr<_Tp2, _Lp>&)
operator==(const __shared_ptr<_Tp1, _Lp>& __a,
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/shared_ptr_base.h:1409:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::__shared_ptr<_Tp1, _Lp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:80:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/unique_ptr.h:694:5: note: candidate: template<class _Tp, class _Dp> bool std::operator==(std::nullptr_t, const std::unique_ptr<_Tp, _Dp>&)
operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/unique_ptr.h:694:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::unique_ptr<_Tp, _Dp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:80:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/unique_ptr.h:689:5: note: candidate: template<class _Tp, class _Dp> bool std::operator==(const std::unique_ptr<_Tp, _Dp>&, std::nullptr_t)
operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/unique_ptr.h:689:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::unique_ptr<_Tp, _Dp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/memory:80:0,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:39,
from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/unique_ptr.h:683:5: note: candidate: template<class _Tp, class _Dp, class _Up, class _Ep> bool std::operator==(const std::unique_ptr<_Tp, _Dp>&, const std::unique_ptr<_Up, _Ep>&)
operator==(const unique_ptr<_Tp, _Dp>& __x,
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/unique_ptr.h:683:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::unique_ptr<_Tp, _Dp>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/random:51:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qrandom.h:45,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:165,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/random.tcc:1878:5: note: candidate: template<class _RealType1> bool std::operator==(const std::normal_distribution<_RealType>&, const std::normal_distribution<_RealType>&)
operator==(const std::normal_distribution<_RealType>& __d1,
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/random.tcc:1878:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::normal_distribution<_RealType>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/functional:58:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qmap.h:54,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtCore/qdebug.h:47,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtCore/QDebug:1,
from ..\Upload\main.cpp:4:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/std_function.h:770:5: note: candidate: template<class _Res, class ... _Args> bool std::operator==(std::nullptr_t, const std::function<_Res(_ArgTypes ...)>&)
operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
^~~~~~~~
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/bits/std_function.h:770:5: note: template argument deduction/substitution failed:
In file included from C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/future:39:0,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/qthread.h:50,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtCore/QtCore:229,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include/QtSql/QtSqlDepends:3,
from C:\Qt\Qt5.12.0\5.12.0\mingw73_64\include\QtSql/QtSql:3,
from ..\Upload\main.cpp:6:
C:/Qt/Qt5.12.0/Tools/mingw730_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/thread:276:33: note: 'std::thread::native_handle_type {aka ptw32_handle_t}' is not derived from 'const std::function<_Res(_ArgTypes ...)>'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
mingw32-make[1]: *** [Makefile.Debug:380: debug/main.o] Error 1
mingw32-make: *** [Makefile:36: debug] Error 2
mingw32-make[1]: Leaving directory 'E:/User/databasePrograms/build-Upload-Desktop_Qt_5_12_0_MinGW_64_bit-Debug'
14:13:52: The process "C:\Qt\Qt5.12.0\Tools\mingw730_64\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project Upload (kit: Desktop Qt 5.12.0 MinGW 64-bit)
When executing step "Make"
14:13:52: Elapsed time: 00:05.
Related
I wanted to try out the new filesystem library in C++17, so tried copying the std::filesystem::current_path example from cppreference.com and compiling it using the latest version (16.0) of the MinGW distribution from nuwen.net on my Windows 10 x64 machine. This includes gcc v8.1 which should support the filesystem library according to cppreference.com compiler support page.
Here is the code that I am trying to compile:
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
std::cout << "Current path is " << fs::current_path() << '\n';
}
And the compiler command I am using:
g++ -std=c++17 filesystem_test.cpp
Here is the error I am getting when trying to compile:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h: In member function 'std::filesystem::__cxx11::path& std::filesystem::__cxx11::path::operator/=(const std::filesystem::__cxx11::path&)':
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:47: error: no match for 'operator!=' (operand types are 'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')
|| (__p.has_root_name() && __p.root_name() != root_name()))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from c:\mingw\include\c++\8.1.0\iosfwd:40,
from c:\mingw\include\c++\8.1.0\ios:38,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\postypes.h:221:5: note: candidate: 'template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)'
operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\postypes.h:221:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::fpos<_StateT>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\stl_algobase.h:64,
from c:\mingw\include\c++\8.1.0\bits\char_traits.h:39,
from c:\mingw\include\c++\8.1.0\ios:40,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\stl_pair.h:456:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\stl_pair.h:456:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::pair<_T1, _T2>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\stl_algobase.h:67,
from c:\mingw\include\c++\8.1.0\bits\char_traits.h:39,
from c:\mingw\include\c++\8.1.0\ios:40,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:311:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
operator!=(const reverse_iterator<_Iterator>& __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:311:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::reverse_iterator<_Iterator>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\stl_algobase.h:67,
from c:\mingw\include\c++\8.1.0\bits\char_traits.h:39,
from c:\mingw\include\c++\8.1.0\ios:40,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:349:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
operator!=(const reverse_iterator<_IteratorL>& __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:349:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::reverse_iterator<_Iterator>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\stl_algobase.h:67,
from c:\mingw\include\c++\8.1.0\bits\char_traits.h:39,
from c:\mingw\include\c++\8.1.0\ios:40,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:1124:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
operator!=(const move_iterator<_IteratorL>& __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:1124:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::move_iterator<_IteratorL>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\stl_algobase.h:67,
from c:\mingw\include\c++\8.1.0\bits\char_traits.h:39,
from c:\mingw\include\c++\8.1.0\ios:40,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:1130:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
operator!=(const move_iterator<_Iterator>& __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\stl_iterator.h:1130:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::move_iterator<_IteratorL>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\string:41,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\allocator.h:158:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_T2>&)'
operator!=(const allocator<_T1>&, const allocator<_T2>&)
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\allocator.h:158:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::allocator<_CharT>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\string:41,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\allocator.h:164:5: note: candidate: 'template<class _Tp> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_CharT>&)'
operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\allocator.h:164:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::allocator<_CharT>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\basic_string.h:48,
from c:\mingw\include\c++\8.1.0\string:52,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\string_view:454:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)'
operator!=(basic_string_view<_CharT, _Traits> __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\string_view:454:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'std::basic_string_view<_CharT, _Traits>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\basic_string.h:48,
from c:\mingw\include\c++\8.1.0\string:52,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\string_view:460:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(std::basic_string_view<_CharT, _Traits>, std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >)'
operator!=(basic_string_view<_CharT, _Traits> __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\string_view:460:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'std::basic_string_view<_CharT, _Traits>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\bits\basic_string.h:48,
from c:\mingw\include\c++\8.1.0\string:52,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\string_view:466:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)'
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
^~~~~~~~
c:\mingw\include\c++\8.1.0\string_view:466:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'std::basic_string_view<_CharT, _Traits>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\string:52,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\basic_string.h:6056:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\basic_string.h:6056:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: 'std::filesystem::__cxx11::path' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\string:52,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\basic_string.h:6069:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
operator!=(const _CharT* __lhs,
^~~~~~~~
c:\mingw\include\c++\8.1.0\bits\basic_string.h:6069:5: note: template argument deduction/substitution failed:
In file included from c:\mingw\include\c++\8.1.0\filesystem:37,
from filesystem_test.cpp:2:
c:\mingw\include\c++\8.1.0\bits\fs_path.h:237:60: note: mismatched types 'const _CharT*' and 'std::filesystem::__cxx11::path'
|| (__p.has_root_name() && __p.root_name() != root_name()))
^
In file included from c:\mingw\include\c++\8.1.0\string:52,
from c:\mingw\include\c++\8.1.0\bits\locale_classes.h:40,
from c:\mingw\include\c++\8.1.0\bits\ios_base.h:41,
from c:\mingw\include\c++\8.1.0\ios:42,
from c:\mingw\include\c++\8.1.0\ostream:38,
from c:\mingw\include\c++\8.1.0\iostream:39,
from filesystem_test.cpp:1:
c:\mingw\include\c++\8.1.0\bits\basic_string.h:6081:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~~~~~
<snip>
Note I had to snip the end of the error message to reduce the character count for this question. I have put the entire error message here: https://pastebin.com/pnfMnMs7
Edit: As per Galik's comment, I tried changing my compiler command to
g++ -std=c++17 filesystem_test.cpp -lstdc++fs
However I seem to get exactly the same error as before
try latest msys2 instead of nuwen distro:
pacman -Syu
pacman -S mingw-w64-x86_64-gcc
gcc -v
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-8.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=ada,c,lto,c++,objc,obj-c++,fortran --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev1, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 8.2.0 (Rev1, Built by MSYS2 project)
I need to recursively iterate through a directory; I got a pretty nice function for it from another thread here on SO; adapted it just a tiny bit for my purposes and it works perfectly on Mac with boost 1.62 and clang.
However, we're using SemaphoreCI (based on ubuntu 14.04 LTS and boost 1.54) and I just cannot get this to compile under those conditions.
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/range.hpp>
void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir)
{
if (!fs::exists(sourceDir) || !fs::is_directory(sourceDir))
{
throw std::runtime_error("Source directory " + sourceDir.string() + " does not exist or is not a directory");
}
if (!fs::create_directory(destinationDir) && !fs::exists(destinationDir))
{
throw std::runtime_error("Cannot create destination directory " + destinationDir.string());
}
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
{
const auto& path = dirEnt.path();
auto relativePathStr = path.string();
boost::algorithm::replace_first(relativePathStr, sourceDir.string(), "");
try {
if (!fs::is_directory(path)) { fs::copy_file(path, destinationDir / relativePathStr); }
else { fs::copy_directory(path, destinationDir / relativePathStr); }
}
catch (...) {
throw std::runtime_error("Cannot copy file " + path.string() + ", because it already exists in the destination folder.");
}
}
}
Here's the error I'm getting,
GCC:
/home/runner/performous/game/fs.cc: In function ‘void copyDirectoryRecursively(const boost::filesystem::path&, const boost::filesystem::path&)’:
/home/runner/performous/game/fs.cc:74:73: error: no matching function for call to ‘begin(boost::filesystem::recursive_directory_iterator&)’
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
^
/home/runner/performous/game/fs.cc:74:73: note: candidates are:
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/boost/variant/variant.hpp:31,
from /home/runner/performous/game/configuration.hh:3,
from /home/runner/performous/game/fs.cc:2:
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution failed:
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/bits/ios_base.h:41,
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
from /usr/include/c++/4.8/ios:42,
from /usr/include/boost/variant/detail/move.hpp:22,
from /usr/include/c++/4.8/iterator:64,
from /usr/include/boost/variant/detail/initializer.hpp:23,
from /usr/include/c++/4.8/iterator:64,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/boost/variant.hpp:17,
begin(_Tp (&__arr)[_Nm])
from /usr/include/boost/variant/detail/move.hpp:22,
from /usr/include/boost/variant/detail/initializer.hpp:23,
from /usr/include/boost/variant/variant.hpp:31,
/home/runner/performous/game/fs.cc:74:73: note: mismatched types ‘_Tp [_Nm]’ and ‘boost::filesystem::recursive_directory_iterator’
from /usr/include/boost/variant.hpp:17,
^
In file included from /usr/include/c++/4.8/string:51:0,
from /home/runner/performous/game/configuration.hh:3,
from /home/runner/performous/game/fs.cc:2:
from /usr/include/c++/4.8/bits/locale_classes.h:40,
begin(const _Container& __cont) -> decltype(__cont.begin())
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = boost::filesystem::recursive_directory_iterator]’:
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution failed:
from /usr/include/c++/4.8/bits/ios_base.h:41,
/home/runner/performous/game/fs.cc:74:73: required from here
/usr/include/c++/4.8/bits/range_access.h:58:5: error: ‘const class boost::filesystem::recursive_directory_iterator’ has no member named ‘begin’
from /usr/include/c++/4.8/ios:42,
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = boost::filesystem::recursive_directory_iterator]’:
/usr/include/c++/4.8/bits/range_access.h:48:5: error: ‘class boost::filesystem::recursive_directory_iterator’ has no member named ‘begin’
/home/runner/performous/game/fs.cc:74:73: required from here
from /usr/include/boost/config/no_tr1/utility.hpp:21,
In file included from /usr/include/c++/4.8/utility:74:0,
from /usr/include/boost/config/select_stdlib_config.hpp:37,
from /usr/include/boost/config.hpp:40,
^
from /usr/include/boost/variant/detail/config.hpp:16,
from /usr/include/boost/variant/variant.hpp:23,
from /usr/include/boost/variant.hpp:17,
from /home/runner/performous/game/configuration.hh:3,
/usr/include/c++/4.8/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
from /home/runner/performous/game/fs.cc:2:
begin(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed:
/home/runner/performous/game/fs.cc:74:73: note: ‘boost::filesystem::recursive_directory_iterator’ is not derived from ‘std::initializer_list<_Tp>’
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
/home/runner/performous/game/fs.cc:74:73: error: no matching function for call to ‘end(boost::filesystem::recursive_directory_iterator&)’
from /usr/include/c++/4.8/bits/locale_classes.h:40,
In file included from /usr/include/c++/4.8/string:51:0,
/home/runner/performous/game/fs.cc:74:73: note: candidates are:
from /usr/include/c++/4.8/iterator:64,
from /usr/include/c++/4.8/bits/ios_base.h:41,
^
from /usr/include/boost/variant/detail/move.hpp:22,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/ios:42,
from /usr/include/boost/variant/detail/initializer.hpp:23,
from /usr/include/boost/variant.hpp:17,
from /home/runner/performous/game/configuration.hh:3,
from /usr/include/boost/variant/variant.hpp:31,
/usr/include/c++/4.8/bits/range_access.h:97:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
from /home/runner/performous/game/fs.cc:2:
/usr/include/c++/4.8/bits/range_access.h:97:5: note: template argument deduction/substitution failed:
^
end(_Tp (&__arr)[_Nm])
/home/runner/performous/game/fs.cc:74:73: note: mismatched types ‘_Tp [_Nm]’ and ‘boost::filesystem::recursive_directory_iterator’
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iterator:64,
from /usr/include/boost/variant/detail/move.hpp:22,
from /usr/include/boost/variant.hpp:17,
from /usr/include/boost/variant/variant.hpp:31,
from /usr/include/boost/variant/detail/initializer.hpp:23,
from /home/runner/performous/game/configuration.hh:3,
from /home/runner/performous/game/fs.cc:2:
^
end(const _Container& __cont) -> decltype(__cont.end())
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = boost::filesystem::recursive_directory_iterator]’:
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution failed:
/home/runner/performous/game/fs.cc:74:73: required from here
/usr/include/c++/4.8/bits/range_access.h:78:5: error: ‘const class boost::filesystem::recursive_directory_iterator’ has no member named ‘end’
end(_Container& __cont) -> decltype(__cont.end())
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&)
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution failed:
^/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = boost::filesystem::recursive_directory_iterator]’:
/home/runner/performous/game/fs.cc:74:73: required from here
/usr/include/c++/4.8/bits/range_access.h:68:5: error: ‘class boost::filesystem::recursive_directory_iterator’ has no member named ‘end’
In file included from /usr/include/c++/4.8/utility:74:0,
from /usr/include/boost/config/no_tr1/utility.hpp:21,
from /usr/include/boost/config/select_stdlib_config.hpp:37,
from /usr/include/boost/config.hpp:40,
from /usr/include/boost/variant/detail/config.hpp:16,
from /usr/include/boost/variant/variant.hpp:23,
from /usr/include/boost/variant.hpp:17,
from /home/runner/performous/game/configuration.hh:3,
from /home/runner/performous/game/fs.cc:2:
/usr/include/c++/4.8/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:99:5: note: template argument deduction/substitution failed:
/home/runner/performous/game/fs.cc:74:73: note: ‘boost::filesystem::recursive_directory_iterator’ is not derived from ‘std::initializer_list<_Tp>’
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
^
make[2]: *** [game/CMakeFiles/performous.dir/fs.cc.o] Error 1
make[1]: *** [game/CMakeFiles/performous.dir/all] Error 2
make: *** [all] Error 2
Clang:
/home/runner/performous/game/fs.cc:74:29: error: invalid range expression of
type 'boost::filesystem::recursive_directory_iterator'; no viable 'begin'
function available
for (const auto& dirEnt : fs::recursive_directory_iterator{sourceDir})
^ ~~
1 error generated.
make[2]: *** [game/CMakeFiles/performous.dir/fs.cc.o] Error 1
make[1]: *** [game/CMakeFiles/performous.dir/all] Error 2
make: *** [all] Error 2
Back then, the iterator didn't model the range concept. So, just make your own range:
for (const auto& dirEnt : boost::make_iterator_range(fs::recursive_directory_iterator{sourceDir}, {})) {
See it Live On GCC 4.8 and Boost 1.54
I have overloaded allocator for most of the stl containers below is the code. The code is from here
#include <iostream>
#include <vector>
#include <list>
namespace outside
{
template<typename T>
struct MyAllocator
{
typedef typename std::allocator<T>::value_type value_type;
typedef typename std::allocator<T>::pointer pointer;
typedef typename std::allocator<T>::const_pointer const_pointer;
typedef typename std::allocator<T>::reference reference;
typedef typename std::allocator<T>::const_reference const_reference;
typedef typename std::allocator<T>::size_type size_type;
pointer allocate (size_type n, typename std::allocator<void>::const_pointer hint=0)
{
std::cerr << "allocate..." << std::endl;
return std::allocator<T>{}.allocate(n, hint);
}
void deallocate (pointer p, size_type n)
{
std::cerr << "deallocate..." << std::endl;
return std::allocator<T>{}.deallocate(p, n);
}
template <class Type> struct rebind
{
typedef MyAllocator<Type> other;
};
MyAllocator()
{
}
MyAllocator(const MyAllocator<T>& other )
{
}
template< class U >
MyAllocator( const MyAllocator<U>& other )
{
}
};
} // namespace outside
namespace outer
{
template<class T>
using vector = ::std::vector<T, outside::MyAllocator<T>>;
template<class T>
using list = ::std::list<T, outside::MyAllocator<T>>;
}
int main()
{
outer::vector<int> myVector1;
outer::vector<int> myVector2;
myVector1.push_back(10);
myVector1.push_back(20);
// myVector2 = myVector1; // Getting compilation error
for (auto i = myVector1.begin(); i != myVector1.end(); ++i) {
std::cout << *i << ' ';
}
std::list<int> myList1;
std::list<int> myList2;
myList2 = myList1; // // No compilation error
}
Copying one vector to another vector is giving me error. While for the same code copying one list to another list is working fine.
Compilation error
included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc: In instantiation of 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = outside::MyAllocator<int>]':
prog.cpp:59:15: required from here
/usr/include/c++/5/bits/vector.tcc:176:37: error: no match for 'operator!=' (operand types are 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' and 'const _Tp_alloc_type {aka const outside::MyAllocator<int>}')
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/iosfwd:40:0,
from /usr/include/c++/5/ios:38,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/postypes.h:221:5: note: candidate: template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
^
/usr/include/c++/5/bits/postypes.h:221:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::fpos<_StateT>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:227:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/include/c++/5/bits/stl_pair.h:227:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::pair<_T1, _T2>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:304:5: note: candidate: template<class _Iterator> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator!=(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:304:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::reverse_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:354:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator!=(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:354:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::reverse_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1077:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator!=(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1077:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::move_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1083:5: note: candidate: template<class _Iterator> bool std::operator!=(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator!=(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1083:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::move_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:41:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/allocator.h:140:5: note: candidate: template<class _T1, class _T2> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_T2>&)
operator!=(const allocator<_T1>&, const allocator<_T2>&)
^
/usr/include/c++/5/bits/allocator.h:140:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::allocator<_CharT>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:41:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/allocator.h:146:5: note: candidate: template<class _Tp> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_CharT>&)
operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
^
/usr/include/c++/5/bits/allocator.h:146:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::allocator<_CharT>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4948:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/5/bits/basic_string.h:4948:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4960:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator!=(const _CharT* __lhs,
^
/usr/include/c++/5/bits/basic_string.h:4960:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: mismatched types 'const _CharT*' and 'outside::MyAllocator<int>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4972:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/5/bits/basic_string.h:4972:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/ios_base.h:46:0,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/system_error:311:3: note: candidate: bool std::operator!=(const std::error_code&, const std::error_code&)
operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
^
/usr/include/c++/5/system_error:311:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_code&'
/usr/include/c++/5/system_error:315:3: note: candidate: bool std::operator!=(const std::error_code&, const std::error_condition&)
operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
^
/usr/include/c++/5/system_error:315:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_code&'
/usr/include/c++/5/system_error:319:3: note: candidate: bool std::operator!=(const std::error_condition&, const std::error_code&)
operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
^
/usr/include/c++/5/system_error:319:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_condition&'
/usr/include/c++/5/system_error:323:3: note: candidate: bool std::operator!=(const std::error_condition&, const std::error_condition&)
operator!=(const error_condition& __lhs,
^
/usr/include/c++/5/system_error:323:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_condition&'
In file included from /usr/include/c++/5/bits/locale_facets.h:48:0,
from /usr/include/c++/5/bits/basic_ios.h:37,
from /usr/include/c++/5/ios:44,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/streambuf_iterator.h:210:5: note: candidate: template<class _CharT, class _Traits> bool std::operator!=(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
^
/usr/include/c++/5/bits/streambuf_iterator.h:210:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/vector:64:0,
from prog.cpp:2:
/usr/include/c++/5/bits/stl_vector.h:1535:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/include/c++/5/bits/stl_vector.h:1535:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::vector<_Tp, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/list:63:0,
from prog.cpp:3:
/usr/include/c++/5/bits/stl_list.h:291:5: note: candidate: template<class _Val> bool std::operator!=(const std::_List_iterator<_Tp>&, const std::_List_const_iterator<_Val>&)
operator!=(const _List_iterator<_Val>& __x,
^
/usr/include/c++/5/bits/stl_list.h:291:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::_List_iterator<_Tp>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/list:63:0,
from prog.cpp:3:
/usr/include/c++/5/bits/stl_list.h:1843:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::list<_Tp, _Alloc>&, const std::list<_Tp, _Alloc>&)
operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
^
/usr/include/c++/5/bits/stl_list.h:1843:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::list<_Tp, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
I am trying to understand why this is the case and solution for this problem ?
The key part of the exception is hundreds of lines into it:
In file included from /usr/local/include/c++/5.2.0/vector:64:0,
from main.cpp:2: /usr/local/include/c++/5.2.0/bits/stl_vector.h:1535:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/local/include/c++/5.2.0/bits/stl_vector.h:1535:5: note: template argument deduction/substitution failed:
In file included from /usr/local/include/c++/5.2.0/vector:69:0,
from main.cpp:2:
/usr/local/include/c++/5.2.0/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::vector<_Tp, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
vector::operator= requires vector::operator!=, which requires allocator::operator!=, which doesn't exist. Without it, the function can't be created. Simply add an operator!= to your allocator. While you're at it, also make sure you have all the other required allocator functions. If memory serves me right, you're missing a fair number.
Change the definition to struct MyAllocator: public std::allocator<T> and the code will compile.
I've been curious about why one error can cause the compiler to generate a very long list of error messages. The following example is the result of an erroneous comparison between an element of a vector<string> and NULL at line 100 of main.cpp under GCC 4.8.1:
> g++ -g3 -std=c++11 main.cpp functions.cpp
main.cpp: In function ‘int main()’:
main.cpp:100:24: error: no match for ‘operator==’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ and ‘long int’)
if(args[1] == NULL) {
^
main.cpp:100:24: note: candidates are:
In file included from /usr/include/c++/4.8/iosfwd:40:0,
from /usr/include/c++/4.8/ios:38,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/postypes.h:216:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
^
/usr/include/c++/4.8/bits/postypes.h:216:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::fpos<_StateT>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_pair.h:214:5: note: template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/include/c++/4.8/bits/stl_pair.h:214:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::pair<_T1, _T2>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_iterator.h:291:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator==(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:291:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::reverse_iterator<_Iterator>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_iterator.h:341:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator==(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:341:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::reverse_iterator<_Iterator>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_iterator.h:1031:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator==(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:1031:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::move_iterator<_Iterator>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_iterator.h:1037:5: note: template<class _Iterator> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator==(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:1037:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::move_iterator<_Iterator>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/string:41:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/allocator.h:128:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_T2>&)
operator==(const allocator<_T1>&, const allocator<_T2>&)
^
/usr/include/c++/4.8/bits/allocator.h:128:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::allocator<_CharT>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/string:41:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/allocator.h:133:5: note: template<class _Tp> bool std::operator==(const std::allocator<_CharT>&, const std::allocator<_CharT>&)
operator==(const allocator<_Tp>&, const allocator<_Tp>&)
^
/usr/include/c++/4.8/bits/allocator.h:133:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::allocator<_CharT>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/basic_string.h:2486:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2486:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: mismatched types ‘const std::basic_string<_CharT, _Traits, _Alloc>’ and ‘long int’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/basic_string.h:2493:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
operator==(const basic_string<_CharT>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2493:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: mismatched types ‘const std::basic_string<_CharT>’ and ‘long int’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/basic_string.h:2507:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator==(const _CharT* __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2507:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: mismatched types ‘const _CharT*’ and ‘std::basic_string<char>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/basic_string.h:2519:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2519:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: mismatched types ‘const _CharT*’ and ‘long int’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/locale_facets.h:48:0,
from /usr/include/c++/4.8/bits/basic_ios.h:37,
from /usr/include/c++/4.8/ios:44,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/streambuf_iterator.h:204:5: note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
^
/usr/include/c++/4.8/bits/streambuf_iterator.h:204:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::istreambuf_iterator<_CharT, _Traits>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/vector:64:0,
from main.h:16,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_vector.h:1403:5: note: template<class _Tp, class _Alloc> bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/include/c++/4.8/bits/stl_vector.h:1403:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::vector<_Tp, _Alloc>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/x86_64-suse-linux/bits/c++allocator.h:33:0,
from /usr/include/c++/4.8/bits/allocator.h:46,
from /usr/include/c++/4.8/string:41,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/ext/new_allocator.h:139:5: note: template<class _Tp> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&)
operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
^
/usr/include/c++/4.8/ext/new_allocator.h:139:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const __gnu_cxx::new_allocator<_Tp>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_iterator.h:811:5: note: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
^
/usr/include/c++/4.8/bits/stl_iterator.h:811:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’
if(args[1] == NULL) {
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from main.h:13,
from main.cpp:12:
/usr/include/c++/4.8/bits/stl_iterator.h:805:5: note: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
^
/usr/include/c++/4.8/bits/stl_iterator.h:805:5: note: template argument deduction/substitution failed:
In file included from /usr/include/unistd.h:226:0,
from main.h:20,
from main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’
if(args[1] == NULL) {
^
This can make it very hard to understand the problem. What is the reason for this behavior?
If you have an expression of the form vec == NULL, the compiler applies ADL to find an appropriate operator== to call. If it can't find a single one it outputs all operator== candidates found in all namespaces considered, and the reason they did not fit here.
One of those can look like this:
In file included from [..] main.cpp:12:
[..]:216:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
^
[..]:216:5: note: template argument deduction/substitution failed:
In file included from [..] main.cpp:12:
main.cpp:100:27: note: ‘__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type {aka std::basic_string<char>}’ is not derived from ‘const std::fpos<_StateT>’
if(args[1] == NULL) {
^
We couldn't match the first parameter to the first argument as std::string isn't derived from any fpos-specialization (also std::string doesn't have any appropriate conversion operators, but that isn't mentioned here). If you defined an operator== that can't be found/called, wouldn't you like to know the reason from the compilers view? (Especially if you don't have a clue yourself)
This can be very useful at times. When it isn't, ignore it. In most cases C++-programmers immediately see and understand what causes the error message (and its enourmos note-section).
This may help in situations like this (you got a large volume of template related message).
Whether your are using make or directly using the compiler, try to pipe the stderr to a file in my example
make 2> error.log
The use any editor open the error.log file. Search for file name of the source code you wrote. There should only be one or two lines that are interesting to you. For example:
mysourcefile.cpp:51:20: required from here
This is where the problem happened; look harder here.
temp_holder.clear();
temp_holder << n;
n_str = temp_holder.str();
int f = count(n_str.begin(), n_str.end(), a);
That's my code, and this is g++ output:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h: In instantiation of ‘typename std::iterator_traits<_InputIterator>::difference_type std::count(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; _Tp = std::basic_string<char>; typename std::iterator_traits<_InputIterator>::difference_type = long int]’:
trintatres.cpp:44:50: required from here
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: error: no match for ‘operator==’ in ‘__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<char*, std::basic_string<char> >() == __value’
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: candidates are:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iosfwd:42:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:39,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/postypes.h:218:5: note: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/postypes.h:218:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::fpos<_StateT>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:65:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:212:5: note: template<class _T1, class _T2> bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:212:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::pair<_T1, _T2>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:68:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:293:5: note: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:293:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:68:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:343:5: note: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:343:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::reverse_iterator<_IteratorL>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:43:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/allocator.h:119:5: note: template<class _T1, class _T2> bool std::operator==(const std::allocator<_T1>&, const std::allocator<_T2>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/allocator.h:119:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::allocator<_T1>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:43:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/allocator.h:124:5: note: template<class _Tp> bool std::operator==(const std::allocator<_Tp1>&, const std::allocator<_Tp1>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/allocator.h:124:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::allocator<_Tp1>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:54:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2483:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2483:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::basic_string<_CharT, _Traits, _Alloc>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:54:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2490:5: note: template<class _CharT> typename __gnu_cxx::__enable_if<std::__is_char<_Tp>::__value, bool>::__type std::operator==(const std::basic_string<_CharT>&, const std::basic_string<_CharT>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2490:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::basic_string<_CharT>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:54:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2504:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2504:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const _CharT*’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:54:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2516:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:2516:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::basic_string<_CharT, _Traits, _Alloc>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_facets.h:50:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_ios.h:39,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:45,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/streambuf_iterator.h:206:5: note: template<class _CharT, class _Traits> bool std::operator==(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/streambuf_iterator.h:206:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const std::istreambuf_iterator<_CharT, _Traits>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu/bits/c++allocator.h:34:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/allocator.h:48,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/string:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/locale_classes.h:42,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:43,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/new_allocator.h:129:5: note: template<class _Tp> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/new_allocator.h:129:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const __gnu_cxx::new_allocator<_Tp>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:68:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:813:5: note: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:813:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’ and ‘char’
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algobase.h:68:0,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/char_traits.h:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:41,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:40,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:40,
from trintatres.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:807:5: note: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_iterator.h:807:5: note: template argument deduction/substitution failed:
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/algorithm:63:0,
from trintatres.cpp:5:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:4656:2: note: mismatched types ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’ and ‘char’
I honestly think I'm using std::count from correctly, according to cplusplus.com.
Any idea of what I'm doing wrong?
EDIT
Full code:
#include <iostream>
#include <string>
#include <sstream>
#include <climits>
#include <algorithm>
using namespace std;
int max(int a, int b) {
return (a > b) ? a : b;
}
int main() {
string a;
cin >> a;
int c;
cin >> c;
int q;
cin >> q;
string cases[q];
int max_case = INT_MIN;
int temp;
for (int i = 0; i < q; i++) {
cin >> temp;
max_case = max(temp, max_case);
stringstream current_case_holder;
current_case_holder << temp;
cases[i] = current_case_holder.str();
}
int sequence[max_case];
int n;
stringstream temp_holder;
string n_str;
for (int i = 0; i < max_case; i++) {
n = 1;
while (true) {
temp_holder.clear();
temp_holder << n;
n_str = temp_holder.str();
int f = count(n_str.begin(), n_str.end(), a);
//}
n++;
}
}
return 0;
}
The first error tells you all you need to know:
In instantiation of ‘typename std::iterator_traits<_InputIterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
[with _IIter = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >;
_Tp = std::basic_string<char>;
typename std::iterator_traits<_InputIterator>::difference_type = long int]’
This indicates that you're passing a std::string object for the third argument to std::count, which is wrong; you need to pass a char object instead, since you're effectively iterating over a std::string, and std::string::value_type is char.