Index: boost/format/format_class.hpp =================================================================== --- boost/format/format_class.hpp (revision 53204) +++ boost/format/format_class.hpp (working copy) @@ -68,6 +68,18 @@ { return io::detail::feed(*this,x); } #endif +#ifdef __GNUC__ + // GCC can't handle anonymous enums without some help + // ** arguments passing ** // + basic_format& operator%(const int& x) + { return io::detail::feed(*this,x); } + +#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST + basic_format& operator%(int& x) + { return io::detail::feed(*this,x); } +#endif +#endif + // ** object modifying **// template basic_format& bind_arg(int argN, const T& val) Index: libs/format/test/format_test_enum.cpp =================================================================== --- libs/format/test/format_test_enum.cpp (revision 0) +++ libs/format/test/format_test_enum.cpp (revision 0) @@ -0,0 +1,45 @@ +// ------------------------------------------------------------------------------ +// format_test_enum.cpp : test format use with enums +// ------------------------------------------------------------------------------ + +// Copyright Steven Watanabe 2009. +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/format for library home page + +// ------------------------------------------------------------------------------ + +#include "boost/format.hpp" + +#define BOOST_INCLUDE_MAIN +#include + +enum enum_plain { PLAIN }; +enum { ANONYMOUS }; +enum enum_overloaded { OVERLOADED }; +typedef enum { OVERLOADED_TYPEDEF } enum_overloaded_typedef; + +std::ostream& operator<<(std::ostream& os, enum_overloaded) { + os << "overloaded"; + return(os); +} + +std::ostream& operator<<(std::ostream& os, enum_overloaded_typedef) { + os << "overloaded"; + return(os); +} + +int test_main(int, char*[]) { + // in this case, we should implicitly convert to int + BOOST_CHECK_EQUAL((boost::format("%d") % PLAIN).str(), "0"); + BOOST_CHECK_EQUAL((boost::format("%d") % ANONYMOUS).str(), "0"); + + // but here we need to use the overloaded operator + BOOST_CHECK_EQUAL((boost::format("%s") % OVERLOADED).str(), "overloaded"); + BOOST_CHECK_EQUAL((boost::format("%s") % OVERLOADED_TYPEDEF).str(), "overloaded"); + + return 0; +} Property changes on: libs\format\test\format_test_enum.cpp ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Index: libs/format/test/Jamfile.v2 =================================================================== --- libs/format/test/Jamfile.v2 (revision 53204) +++ libs/format/test/Jamfile.v2 (working copy) @@ -18,6 +18,7 @@ [ run format_test2.cpp ] [ run format_test3.cpp ] [ run format_test_wstring.cpp ] + [ run format_test_enum.cpp ] ; }