After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 599340 - MSVS 2005: Glib::ustring::format does not work with std::fixed or std::setfill
MSVS 2005: Glib::ustring::format does not work with std::fixed or std::setfill
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2009-10-22 19:56 UTC by Armin Burgmeier
Modified: 2010-04-12 17:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Armin Burgmeier 2009-10-22 19:56:33 UTC
For std::setfill I see the following error with MSVC:

1>c:\msys\home\armin\gnome\glibmm\glib\glibmm\ustring.h(1052) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::_Fillobj<_Elem>' (or there is no acceptable conversion)

For std::fixed, it is (there are many, but I think this is the relevant one):

1>c:\msys\home\armin\gnome\glibmm\examples\compose\main.cc(40) : error C2784: 'Glib::ustring Glib::ustring::format(const T1 &,const T2 &,const T3 &)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'

To reproduce, simply try to compile the compose example from the glibmm tarball.

I have no actual idea how to tackle this... I assume the latter means that std::fixed is overloaded in MSVC's STL. If that's allowed by the standard then we should maybe at least offer an alternative way of setting std::fixed with Glib::ustring::format.
Comment 1 Daniel Elstner 2010-03-29 09:36:15 UTC
Is glibmm on Windows now compiled with wide stream support, as discussed a while ago on the mailing list?
Comment 2 Armin Burgmeier 2010-04-02 14:42:36 UTC
I am going to do this for gtkmm 2.20 and MSVC. It does not solve this problem though.
Comment 3 Murray Cumming 2010-04-07 13:04:03 UTC
Thanks, Armin, if that doesn't fix this, please show us the latest compile error here.
Comment 4 Armin Burgmeier 2010-04-07 14:03:56 UTC
Oh, the first time I didn't realize this is a different error, but it is:

1>..\..\..\..\..\..\..\msys\home\Armin\gnome\glibmm\examples\compose\main.cc(40) : error C2780: 'Glib::ustring Glib::ustring::format(const T1 &,const T2 &,const T3 &,const T4 &,const T5 &,const T6 &,const T7 &,const T8 &)' : expects 8 arguments - 3 provided
1>        C:\gtkmm\include\glibmm-2.4\glibmm/ustring.h(796) : see declaration of 'Glib::ustring::format'
1>..\..\..\..\..\..\..\msys\home\Armin\gnome\glibmm\examples\compose\main.cc(40) : error C2780: 'Glib::ustring Glib::ustring::format(const T1 &,const T2 &,const T3 &,const T4 &,const T5 &,const T6 &,const T7 &)' : expects 7 arguments - 3 provided

The same message appears for all the other overloads except for the one with 3 arguments. Also the same error appears for ustring::compose for all the overloads:

1>..\..\..\..\..\..\..\msys\home\Armin\gnome\glibmm\examples\compose\main.cc(40) : error C2780: 'Glib::ustring Glib::ustring::compose(const Glib::ustring &,const T1 &,const T2 &,const T3 &,const T4 &,const T5 &,const T6 &,const T7 &,const T8 &,const T9 &)' : expects 10 arguments - 4 provided
1>        C:\gtkmm\include\glibmm-2.4\glibmm/ustring.h(698) : see declaration of 'Glib::ustring::compose'
1>..\..\..\..\..\..\..\msys\home\Armin\gnome\glibmm\examples\compose\main.cc(40) : error C2780: 'Glib::ustring Glib::ustring::compose(const Glib::ustring &,const T1 &,const T2 &,const T3 &,const T4 &,const T5 &,const T6 &,const T7 &,const T8 &)' : expects 9 arguments - 4 provided
1>        C:\gtkmm\include\glibmm-2.4\glibmm/ustring.h(687) : see declaration of 'Glib::ustring::compose'

Another thing I just checked is that this error happens only with VC8 (MSVC 2005) but it compiles OK with VC9 (MSVC 2008). It seems to be only due to the std::fixed; if I remove it then it also compiles with MSVC 2005.
Comment 5 Armin Burgmeier 2010-04-07 14:18:06 UTC
Just for the record: When casting it to the correct type then it compiles also with MSVC 2005:

ustring::format(static_cast<std::ios_base&(*)(std::ios_base&)>(std::fixed), std::setprecision(1), a / b * 100.0))

Maybe this is because it's (incorrectly?) overloaded. I can't seem to be able to find out how/with what though.
Comment 6 Murray Cumming 2010-04-12 08:19:54 UTC
> Another thing I just checked is that this error happens only with VC8 (MSVC
> 2005) but it compiles OK with VC9 (MSVC 2008).

Then it's probably not worth worrying about much, particularly as it's only in an example, so you can still build glibmm for MSVS 2005, but people just can't use that (new) API.

Of course I'd welcome a patch to fix it on that old compiler, but I wouldn't waste time creating that patch personally,
Comment 7 Daniel Elstner 2010-04-12 12:02:31 UTC
I take it that the std::setfill() example compiles fine now?

About fixing it: Let's not do that horrible cast. At most, I would exclude the line using std::fixed from the build on MSVC 2005. But given that, if I remember correctly, the examples are only built on "make check", we may as well leave it as it is.
Comment 8 Armin Burgmeier 2010-04-12 12:13:47 UTC
Yes, std::setfill seems to work since wide streams were enabled.

I normally add the examples to the MSVC solution file so I can easily verify they keep working. If we decide to leave things as they are then I can simply add this one only to the MSVC2008 project.
Comment 9 Daniel Elstner 2010-04-12 12:20:35 UTC
Well, if it would make your life easier, feel free to conditionally disable the std::fixed bit for MSVC 2005. The decision is yours.
Comment 10 Armin Burgmeier 2010-04-12 17:20:25 UTC
OK. I have added a check for MSVC 2008 or above and added the file to both projects.