Search code examples
c++c++11localeclang

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


I'm attempting to build the following application; pinched from 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.

I've removed the third argument to open and all is well. The problem is i wish to specify a location for my text domain other than the default. I've looked into bindtextdomain but fail to get that recognised on my machine as well. Any hints?

Environment:

  • Mac OSX Lion
  • Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
  • Target: x86_64-apple-darwin11.2.0
  • Thread model: posix

Solution

  • This issue was addressed at cppreference.com. see comments section above.

    The example on cppreference.com is now updated to use the standard messages::open