{"action":"closed","issue":{"url":"https://api.github.com/repos/cppformat/cppformat/issues/247","labels_url":"https://api.github.com/repos/cppformat/cppformat/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/cppformat/cppformat/issues/247/comments","events_url":"https://api.github.com/repos/cppformat/cppformat/issues/247/events","html_url":"https://github.com/cppformat/cppformat/issues/247","id":122972188,"number":247,"title":"operator bool","user":{"login":"bumbar1","id":2507237,"avatar_url":"https://avatars.githubusercontent.com/u/2507237?v=3","gravatar_id":"","url":"https://api.github.com/users/bumbar1","html_url":"https://github.com/bumbar1","followers_url":"https://api.github.com/users/bumbar1/followers","following_url":"https://api.github.com/users/bumbar1/following{/other_user}","gists_url":"https://api.github.com/users/bumbar1/gists{/gist_id}","starred_url":"https://api.github.com/users/bumbar1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bumbar1/subscriptions","organizations_url":"https://api.github.com/users/bumbar1/orgs","repos_url":"https://api.github.com/users/bumbar1/repos","events_url":"https://api.github.com/users/bumbar1/events{/privacy}","received_events_url":"https://api.github.com/users/bumbar1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-18T15:50:11Z","updated_at":"2015-12-18T16:14:00Z","closed_at":"2015-12-18T16:14:00Z","body":"Not sure if it's a bug (maybe it's expected behavior because of `bool`?), but if you define a custom data type with `operator bool` (regardless of return value) and `operator <<`, then formatting doesn't work.\r\n\r\nExample code:\r\n```\r\n#include <iostream>\r\n#include <string>\r\n#include \"cppformat/format.h\"\r\n\r\nstruct Date {\r\n    operator bool() const { return true; }\r\n    friend\r\n    std::ostream& operator << (std::ostream& os, const Date& date) { return os << \"1.1.1970\"; }\r\n};\r\n\r\nint main() {\r\n    std::cout << \"date is \" << Date{} << \"\\n\";\r\n    std::cout << fmt::format(\"date is {}\\n\", Date{}); // prints \"date is 1\"\r\n}\r\n```\r\n"}}