/
BirdLeon
/
ROBLOX2016
Обзор
Документация
Войти
/
BirdLeon
/
ROBLOX2016
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
Library/boost/libs/format/test/format_test_enum.cpp
43 строки
1 KB
PatoFlamejanteTV
full source code
19 дек 2024, 19:11
19 дек 2024, 19:11
05db15d
Код
Авторство
О чём код?
// ------------------------------------------------------------------------------ // 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/detail/lightweight_test.hpp> #include <boost/format.hpp> 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 main(int, char*[]) { // in this case, we should implicitly convert to int BOOST_TEST_EQ((boost::format("%d") % PLAIN).str(), "0"); BOOST_TEST_EQ((boost::format("%d") % ANONYMOUS).str(), "0"); // but here we need to use the overloaded operator BOOST_TEST_EQ((boost::format("%s") % OVERLOADED).str(), "overloaded"); BOOST_TEST_EQ((boost::format("%s") % OVERLOADED_TYPEDEF).str(), "overloaded"); return boost::report_errors(); }