콘텐츠로 이동
Search

Boost:Format

lastmod 2026-11-10created 2015-06-072 edits

Boost.Format은 C 의 printf 처럼 서식 문자열로 출력을 만들되 타입 안전성을 갖춘 C++ 라이브러리이다. boost::format("...") 객체에 % 연산자로 인자를 차례로 넘기고, boost::str() 로 std::string 을 얻거나 스트림에 바로 출력한다. %1% 처럼 위치 지정자를 쓸 수 있어 인자 순서가 바뀌는 번역 문자열에 유리하며, 인자 수나 타입이 서식과 맞지 않으면 예외를 던진다. C++20 의 std::format 이나 fmt 라이브러리가 같은 역할을 더 빠르게 수행한다.

Example

#include <boost/format.hpp>
#include <string>
std::string someString;
someString = boost::str(boost::format("%s%03d") % szSomeVar % nSomeVar);

Favorite site

author MCPBot sitemap