drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.44k stars 1.1k forks source link

Cannot compile with a new trantor #1621

Closed nqf closed 1 year ago

nqf commented 1 year ago
In file included from /fantasy-peak/drogon/lib/inc/drogon/utils/HttpConstraint.h:17,
                 from /fantasy-peak/drogon/lib/inc/drogon/HttpAppFramework.h:20,
                 from /fantasy-peak/drogon/lib/src/HttpAppFrameworkImpl.h:17,
                 from /fantasy-peak/drogon/lib/src/HttpAppFrameworkImpl.cc:15:
/fantasy-peak/drogon/lib/inc/drogon/HttpTypes.h: In function ‘trantor::LogStream& drogon::operator<<(trantor::LogStream&, drogon::ReqResult)’:
/fantasy-peak/drogon/lib/inc/drogon/HttpTypes.h:215:16: error: ambiguous overload for ‘operator<<’ (operand types are ‘trantor::LogStream’ and ‘std::string_view’ {aka ‘std::basic_string_view<char>’})
  215 |     return out << to_string_view(result);
      |            ~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~
      |            |                    |
      |            trantor::LogStream   std::string_view {aka std::basic_string_view<char>}
In file included from /fantasy-peak/drogon/lib/inc/drogon/utils/string_view.h:24,
                 from /fantasy-peak/drogon/lib/inc/drogon/HttpTypes.h:18,
                 from /fantasy-peak/drogon/lib/inc/drogon/utils/HttpConstraint.h:17,
                 from /fantasy-peak/drogon/lib/inc/drogon/HttpAppFramework.h:20,
                 from /fantasy-peak/drogon/lib/src/HttpAppFrameworkImpl.h:17,
                 from /fantasy-peak/drogon/lib/src/HttpAppFrameworkImpl.cc:15:
/fantasy-peak/drogon/trantor/trantor/utils/LogStream.h:208:11: note: candidate: ‘trantor::LogStream::self& trantor::LogStream::operator<<(std::string_view)’
  208 |     self &operator<<(const std::string_view v)
      |           ^~~~~~~~
In file included from /fantasy-peak/drogon/lib/inc/drogon/HttpTypes.h:18,
                 from /fantasy-peak/drogon/lib/inc/drogon/utils/HttpConstraint.h:17,
                 from /fantasy-peak/drogon/lib/inc/drogon/HttpAppFramework.h:20,
                 from /fantasy-peak/drogon/lib/src/HttpAppFrameworkImpl.h:17,
                 from /fantasy-peak/drogon/lib/src/HttpAppFrameworkImpl.cc:15:
/fantasy-peak/drogon/lib/inc/drogon/utils/string_view.h:36:19: note: candidate: ‘trantor::LogStream& trantor::operator<<(trantor::LogStream&, const string_view&)’
   36 | inline LogStream &operator<<(LogStream &ls, const drogon::string_view &v)
an-tao commented 1 year ago

6:19: note: candidate: ‘trantor::LogStream& trantor::operator<<(trantor::LogStream&, const string_view&)’ 36 | inline LogStream &operator<<(LogStream &ls, const drogon::string_view &v)

Try to move the trantor::LogStream& trantor::operator<<(trantor::LogStream&, const string_view&) to the boost::string_view section.

nqf commented 1 year ago

Now it's okay

namespace drogon
{
#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
using std::string_view;
#else
using boost::string_view;

namespace trantor
{
inline LogStream &operator<<(LogStream &ls, const drogon::string_view &v)
{
    ls.append(v.data(), v.length());
    return ls;
}
}  // namespace trantor

#endif
}  // namespace drogon