金庆的专栏

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  423 随笔 :: 0 文章 :: 454 评论 :: 0 Trackbacks
封装boost::format

(金庆的专栏)

boost::format()大量使用,只是函数名太长了点,需要简化。
原因2就是希望Release版不要因为格式化参数多了少了而抛异常。
原因3就是boost::format中有文件包含特殊字符,出C4819警告。

// fmt.h
#ifndef __FMT_H__
#define __FMT_H__

#pragma warning( push )
#pragma warning( disable: 4819 )
// Disable boost/format/alt_sstream_impl.hpp : warning C4819: ...
#include <boost/format.hpp>
#pragma warning( pop )

namespace {

boost::format fmt(const std::string & sFmt)
{
    boost::format fmter(sFmt);
#ifdef NDEBUG
    fmter.exceptions(boost::io::no_error_bits);
#endif    
    return fmter;
}

}  // namespace

#endif  // __FMT_H__
posted on 2012-12-17 17:18 金庆 阅读(1009) 评论(0)  编辑 收藏 引用 所属分类: 1. C/C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理