I moved my MFC app to C++17 a while back and everything is great. I wanted to use std::to_chars
so included in the cpp file. Didn't work. Tried to put it early in the StdAfx.h, same error(s).
Then I tried it with a console app and even if I add a boat load of headers used in the MFC app, I don't get the errors. The errors are some kind of header include conflicts, They come up just compiling StdAfx.h. It happens even if I make it the first file in StdAfx.h. I've alt-tabed between the properties of both projects and they are the same for all practical purposes.
UPDATE
I'm using: SDK 10.0 (latest installed version) Visual Studio 2019 (v142) Version 16.4.2 ISO C++17 Standard (std:c++17)
In the console app, I tried it both with and without pre-compiled headers and it works both ways. I've posted the complete error message with included in one cpp file.
I'm wondering if there is something lurking in my project file. It is 20 years old now brought up from VS6. For now I'll just use auto str(std::to_wstring(cur));
My next step is to create a clean project and copy my app source to that. Need to do try that anyway as it may fix this, I still can not add variables with the wizard.
The errors are while compiling <charconv>
:
\charconv(1503,68): error C2672: 'std::_Max_value': no matching overloaded function found
\charconv(1912): message : see reference to function template instantiation 'std::errc std::_Convert_decimal_string_to_floating_type<_Floating>(const std::_Floating_point_string &,_FloatingType &,bool) noexcept' being compiled
1> with
1> [
1> _Floating=float,
1> _FloatingType=float
1> ]
\charconv(2053): message : see reference to function template instantiation 'std::from_chars_result std::_Ordinary_floating_from_chars<_Floating>(const char *const ,const char *const ,_Floating &,const std::chars_format,const bool,const char *) noexcept' being compiled
1> with
1> [
1> _Floating=float
1> ]
\charconv(2065): message : see reference to function template instantiation 'std::from_chars_result std::_Floating_from_chars<float>(const char *const ,const char *const ,_Floating &,const std::chars_format) noexcept' being compiled
1> with
1> [
1> _Floating=float
1> ]
\charconv(1503,1): error C2782: 'const _Ty &std::_Max_value(const _Ty &,const _Ty &) noexcept(<expr>)': template parameter '_Ty' is ambiguous
\utility(35): message : see declaration of 'std::_Max_value'
\charconv(1503,1): message : could be 'int32_t'
\charconv(1503,1): message : or 'int'
\charconv(1503,1): error C2784: 'const _Ty &std::_Max_value(const _Ty &,const _Ty &) noexcept(<expr>)': could not deduce template argument for 'const _Ty &' from 'const int32_t'
\utility(35): message : see declaration of 'std::_Max_value'
\charconv(1503,44): error C2789: '_Positive_exponent': an object of const-qualified type must be initialized
\charconv(1503): message : see declaration of '_Positive_exponent'
The headers I added to the console app without creating the issue:
#include <boost/date_time/gregorian/greg_date.hpp>
#include <boost/locale.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/spirit/home/x3.hpp>
#include <SDKDDKVer.h>
#include <intsafe.h>
#include <afxwin.h> // MFC core and standard components
#include <charconv>
#include <afxrich.h> // MFC Rich Edit Control used in most.
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdb.h> // ODBC support
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#include <afxcmn.h> // MFC support for Windows Common Controls
#include <afxcview.h> // MFC Common controls
#include <afxdhtml.h> // html support
#include <afxdlgs.h> // Common Dialogs
#include <afxtempl.h> // MFC template support.
#include <atlimage.h> // GDIPlus, not....
#include <raserror.h> // ERROR_ defines
#include <direct.h> // for _tchdir( GetProjectDirectory( ) );
#include <shlobj.h> // SHGetFolderPath(...)
#include <afxdialogex.h> //for ReTreeDlg
#include <gdiplus.h> // GDIPlus
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <boost/asio/connect.hpp>
#include <boost/bind.hpp>
#include <boost/exception/exception.hpp>
#include <boost/thread.hpp>
#include <boost/variant.hpp>
#include <boost/lexical_cast.hpp>
Nine times out of ten I'll figure it out while writing my question. This is a one time and I'm at a loss. Just hoping someone has seen the likes of this before.