clang++ C++0x std::locale

clang++ C++0x std::locale

本文关键字:locale std C++0x clang++      更新时间:2023-10-16

我正在尝试构建以下应用程序;从http://en.cppreference.com/w/cpp/locale/messages.

#include <iostream>
#include <locale>
int main()
{
    std::locale loc("de_DE");    
    auto& facet = std::use_facet<std::messages<char>>(loc);
    auto cat = facet.open("libstdc++", loc, "/usr/share/locale");
    std::cout << ""please" in German: "
              << facet.get(cat, 0, 0, "please") << 'n'
              << ""thank you" in German: "
              << facet.get(cat, 0, 0, "thank you") << 'n';
    facet.close(cat);
}
main.cpp:134:45: error: too many arguments to function call, expected 2, have 3
    auto cat = facet.open("libstdc++", loc, "/usr/share/locale");
               ~~~~~~~~~~                   ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/locale:3528:5: note: 'open' declared here
    _LIBCPP_ALWAYS_INLINE
    ^
/usr/include/c++/v1/__config:84:32: note: instantiated from:
#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
                               ^
1 error generated.

我已经删除了打开的第三个参数,一切正常。问题是我希望为我的文本域指定一个位置,而不是默认的。我已经查看了bindtextdomain,但未能在我的机器上识别。有提示吗?

环境:

  • Mac OSX Lion
  • Apple clang version 2.1 (tags/Apple/clang-163.7.1)(基于LLVM 3.0svn)
  • 目标:x86_64-apple-darwin11.2.0
  • 线程模型:posix

此问题已在cppreference.com上解决。请看上面的评论部分。

cppreference.com上的示例现在已更新为使用该标准消息::打开