/************************************************************************** * * moneyput.cpp - Example program for the money_put facet. * * $Id: moneyput.cpp 550991 2007-06-26 23:58:07Z sebor $ * *************************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. * * Copyright 1994-2006 Rogue Wave Software. * **************************************************************************/ #include // for locale, money_put, use_facet #include // for cout, endl #include // for ostreambuf_iterator #include // for string #include int main () { typedef std::ostreambuf_iterator > Iter; const std::string buffer ("10002"); const long double ldval = 10002; // Construct a ostreambuf_iterator on cout Iter begin (std::cout); const std::locale loc; // Get a money put facet const std::money_put &mp = std::use_facet >(loc); // Put out the string representation of the monetary value std::cout << buffer << " --> "; mp.put (begin, false, std::cout, ' ', buffer); // Put out the long double representation of the monetary value std::cout << std::endl << ldval << " --> "; mp.put (begin, false, std::cout, ' ', ldval); std::cout << std::endl; return 0; }