From 71a16cd8bcb8d112a2a1db544b7f3aa9cfea67f8 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 20 Jan 2015 11:50:51 +0000 Subject: [PATCH] Add C++11 std::string constructors for locales and facets. * config/abi/pre/gnu.ver: Export new constructors. * include/bits/codecvt.h (codecvt_byname): Add string constructor. (codecvt_byname, codecvt_byname): Define explicit specializations and declare explicit instantiations. * include/bits/locale_classes.h (locale, collate_byname): Add string constructors. * include/bits/locale_facets.h (ctype_byname, numpunct_byname): Likewise. * include/bits/locale_facets_nonio.h (time_get_byname, time_put_byname, moneypunct_byname, messages_byname): Likewise. * src/c++11/codecvt.cc (codecvt_byname, codecvt_byname): Define explicit instantiations. * src/c++11/locale-inst.cc (time_put_byname, codecvt_byname): Instantiate string constructors. (ctype_byname): Define string constructor. * testsuite/22_locale/codecvt_byname/1.cc: New. * testsuite/22_locale/collate_byname/1.cc: New. * testsuite/22_locale/ctype_byname/2.cc: New. * testsuite/22_locale/messages_byname/1.cc: New. * testsuite/22_locale/moneypunct_byname/1.cc: New. * testsuite/22_locale/numpunct_byname/1.cc: New. From-SVN: r219887 --- libstdc++-v3/ChangeLog | 24 +++++++++ libstdc++-v3/config/abi/pre/gnu.ver | 37 ++++++++++++-- libstdc++-v3/include/bits/codecvt.h | 50 +++++++++++++++++++ libstdc++-v3/include/bits/locale_classes.h | 34 +++++++++++++ libstdc++-v3/include/bits/locale_facets.h | 22 ++++++++ .../include/bits/locale_facets_nonio.h | 24 +++++++++ libstdc++-v3/src/c++11/codecvt.cc | 2 + libstdc++-v3/src/c++11/locale-inst.cc | 9 ++++ .../testsuite/22_locale/codecvt_byname/1.cc | 46 +++++++++++++++++ .../testsuite/22_locale/collate_byname/1.cc | 46 +++++++++++++++++ .../testsuite/22_locale/ctype_byname/2.cc | 46 +++++++++++++++++ .../testsuite/22_locale/messages_byname/1.cc | 46 +++++++++++++++++ .../22_locale/moneypunct_byname/1.cc | 48 ++++++++++++++++++ .../testsuite/22_locale/numpunct_byname/1.cc | 46 +++++++++++++++++ 14 files changed, 477 insertions(+), 3 deletions(-) create mode 100644 libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/collate_byname/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/ctype_byname/2.cc create mode 100644 libstdc++-v3/testsuite/22_locale/messages_byname/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc create mode 100644 libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 92e51f04856..7410bbccfe0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,27 @@ +2015-01-20 Jonathan Wakely + + * config/abi/pre/gnu.ver: Export new constructors. + * include/bits/codecvt.h (codecvt_byname): Add string constructor. + (codecvt_byname, codecvt_byname): Define explicit + specializations and declare explicit instantiations. + * include/bits/locale_classes.h (locale, collate_byname): Add string + constructors. + * include/bits/locale_facets.h (ctype_byname, numpunct_byname): + Likewise. + * include/bits/locale_facets_nonio.h (time_get_byname, + time_put_byname, moneypunct_byname, messages_byname): Likewise. + * src/c++11/codecvt.cc (codecvt_byname, + codecvt_byname): Define explicit instantiations. + * src/c++11/locale-inst.cc (time_put_byname, codecvt_byname): + Instantiate string constructors. + (ctype_byname): Define string constructor. + * testsuite/22_locale/codecvt_byname/1.cc: New. + * testsuite/22_locale/collate_byname/1.cc: New. + * testsuite/22_locale/ctype_byname/2.cc: New. + * testsuite/22_locale/messages_byname/1.cc: New. + * testsuite/22_locale/moneypunct_byname/1.cc: New. + * testsuite/22_locale/numpunct_byname/1.cc: New. + 2015-01-20 Jonathan Wakely PR libstdc++/64658 diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index d23306e7c76..61024bd7c04 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -64,8 +64,10 @@ GLIBCXX_3.4 { # std::char_traits; # std::c[i-z]*; std::c[i-n]*; +# std::collate; +# std::collate_byname; # std::condition_variable; - std::co[^n]*; + std::co[^ln]*; std::c[p-s]*; std::cu[^r]*; # std::current_exception @@ -527,6 +529,14 @@ GLIBCXX_3.4 { # std::use_facet _ZSt9use_facetIS*; + # std::collate + _ZNSt7collateI[cw]*; + _ZNKSt7collateI[cw]*; + + # std::collate_byname + _ZNSt14collate_bynameI[cw]EC[12]EPKc?*; + _ZNSt14collate_bynameI[cw]ED*; + # std::ctype _ZNKSt5ctypeIcE8*; _ZNKSt5ctypeIcE9*; @@ -538,7 +548,8 @@ GLIBCXX_3.4 { _ZNSt10ctype_base[56][ac-z]*; # std::ctype_byname - _ZNSt12ctype_bynameI[cw]*; + _ZNSt12ctype_bynameI[cw]EC[12]EPKc?*; + _ZNSt12ctype_bynameI[cw]ED*; # std::num_get _ZNKSt7num_getI[cw]St19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEE[2-9]*; @@ -573,7 +584,8 @@ GLIBCXX_3.4 { _ZNKSt8time_put*; # std::time_put_byname - _ZNSt15time_put_byname*; + _ZNSt15time_put_bynameI[cw]*EC[12]EPKc?*; + _ZNSt15time_put_bynameI[cw]*ED[012]Ev; # std::numeric_limits _ZNSt21__numeric_limits_base[5-9]*; @@ -1780,6 +1792,25 @@ GLIBCXX_3.4.21 { _ZNSt25__codecvt_utf8_utf16_base*; _ZT[ISV]St25__codecvt_utf8_utf16_base*; + # new string ctors for _byname facets + _ZNSt12ctype_bynameI[cw]EC[1-5]ERKSsm; + _ZNSt14codecvt_bynameI[cw]c11__mbstate_tEC[1-5]ERKSsm; + _ZNSt15messages_bynameI[cw]EC[1-5]ERKSsm; + _ZNSt15numpunct_bynameI[cw]EC[1-5]ERKSsm; + _ZNSt15time_get_bynameI[cw]St19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEEC[1-5]ERKSsm; + _ZNSt15time_put_bynameI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEEC[1-5]ERKSsm; + _ZNSt17moneypunct_bynameI[cw]Lb0EEC[1-5]ERKSsm; + _ZNSt17moneypunct_bynameI[cw]Lb1EEC[1-5]ERKSsm; + + _ZNSt12ctype_bynameI[cw]EC[1-5]ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm; + _ZNSt14codecvt_bynameI[cw]c11__mbstate_tEC[1-5]ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEm; + _ZNSt15time_put_bynameI[cw]St19ostreambuf_iteratorI[cw]St11char_traitsI[cw]EEEC[1-5]ERKNSt7__cxx1112basic_stringIcS2_SaIcEEEm; + _ZNSt7__cxx1115messages_bynameI[cw]EC[1-5]ERKNS_12basic_stringIcSt11char_traitsIcESaIcEEEm; + _ZNSt7__cxx1115numpunct_bynameI[cw]EC[1-5]ERKNS_12basic_stringIcSt11char_traitsIcESaIcEEEm; + _ZNSt7__cxx1115time_get_bynameI[cw]St19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEEC[1-5]ERKNS_12basic_stringIcS3_SaIcEEEm; + _ZNSt7__cxx1117moneypunct_bynameI[cw]Lb0EEC[1-5]ERKNS_12basic_stringIcSt11char_traitsIcESaIcEEEm; + _ZNSt7__cxx1117moneypunct_bynameI[cw]Lb1EEC[1-5]ERKNS_12basic_stringIcSt11char_traitsIcESaIcEEEm; + } GLIBCXX_3.4.20; diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h index a6e59b5128f..c76215f87f5 100644 --- a/libstdc++-v3/include/bits/codecvt.h +++ b/libstdc++-v3/include/bits/codecvt.h @@ -594,11 +594,55 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if __cplusplus >= 201103L + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~codecvt_byname() { } + }; + +#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1) + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char* __s, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + protected: virtual ~codecvt_byname() { } }; + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char* __s, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; +#endif + // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. #if _GLIBCXX_EXTERN_TEMPLATE @@ -623,6 +667,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool has_facet >(const locale&); #endif + +#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1) + extern template class codecvt_byname; + extern template class codecvt_byname; +#endif + #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h index f591437f148..f3898ebf7b2 100644 --- a/libstdc++-v3/include/bits/locale_classes.h +++ b/libstdc++-v3/include/bits/locale_classes.h @@ -150,6 +150,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ locale(const locale& __base, const char* __s, category __cat); +#if __cplusplus >= 201103L + /** + * @brief Named locale constructor. + * + * Constructs a copy of the named C library locale. + * + * @param __s Name of the locale to construct. + * @throw std::runtime_error if __s is an undefined locale. + */ + explicit + locale(const std::string& __s) : locale(__s.c_str()) { } + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale named by @a s. If base is + * named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __s Name of the locale to use facets from. + * @param __cat Set of categories defining the facets to use from __s. + * @throw std::runtime_error if __s is an undefined locale. + */ + locale(const locale& __base, const std::string& __s, category __cat) + : locale(__base, __s.c_str(), __cat) { } +#endif + /** * @brief Construct locale with facets from another locale. * @@ -797,6 +825,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if __cplusplus >= 201103L + explicit + collate_byname(const string& __s, size_t __refs = 0) + : collate_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~collate_byname() { } diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 77932a5060b..0226b497c30 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -1479,6 +1479,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit ctype_byname(const char* __s, size_t __refs = 0); +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0) + : ctype_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~ctype_byname() { }; @@ -1492,6 +1498,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit ctype_byname(const char* __s, size_t __refs = 0); +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0); +#endif + protected: virtual ~ctype_byname(); @@ -1505,6 +1516,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit ctype_byname(const char* __s, size_t __refs = 0); +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0); +#endif + protected: virtual ~ctype_byname(); @@ -1900,6 +1916,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } } +#if __cplusplus >= 201103L + explicit + numpunct_byname(const string& __s, size_t __refs = 0) + : numpunct_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~numpunct_byname() { } diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.h b/libstdc++-v3/include/bits/locale_facets_nonio.h index 0c49880b0d3..7eae6c80653 100644 --- a/libstdc++-v3/include/bits/locale_facets_nonio.h +++ b/libstdc++-v3/include/bits/locale_facets_nonio.h @@ -766,6 +766,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 time_get_byname(const char*, size_t __refs = 0) : time_get<_CharT, _InIter>(__refs) { } +#if __cplusplus >= 201103L + explicit + time_get_byname(const string& __s, size_t __refs = 0) + : time_get_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~time_get_byname() { } @@ -894,6 +900,12 @@ _GLIBCXX_END_NAMESPACE_CXX11 : time_put<_CharT, _OutIter>(__refs) { }; +#if __cplusplus >= 201103L + explicit + time_put_byname(const string& __s, size_t __refs = 0) + : time_put_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~time_put_byname() { } @@ -1419,6 +1431,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 } } +#if __cplusplus >= 201103L + explicit + moneypunct_byname(const string& __s, size_t __refs = 0) + : moneypunct_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~moneypunct_byname() { } @@ -1969,6 +1987,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 explicit messages_byname(const char* __s, size_t __refs = 0); +#if __cplusplus >= 201103L + explicit + messages_byname(const string& __s, size_t __refs = 0) + : messages_byname(__s.c_str(), __refs) { } +#endif + protected: virtual ~messages_byname() diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc index 7eed903bc0c..594dae6810c 100644 --- a/libstdc++-v3/src/c++11/codecvt.cc +++ b/libstdc++-v3/src/c++11/codecvt.cc @@ -1402,6 +1402,8 @@ __codecvt_utf8_utf16_base::do_max_length() const throw() inline template class __codecvt_abstract_base; inline template class __codecvt_abstract_base; +template class codecvt_byname; +template class codecvt_byname; _GLIBCXX_END_NAMESPACE_VERSION } diff --git a/libstdc++-v3/src/c++11/locale-inst.cc b/libstdc++-v3/src/c++11/locale-inst.cc index 573da4d433e..9240b407f15 100644 --- a/libstdc++-v3/src/c++11/locale-inst.cc +++ b/libstdc++-v3/src/c++11/locale-inst.cc @@ -192,6 +192,9 @@ _GLIBCXX_END_NAMESPACE_LDBL template struct __timepunct_cache; template class time_put >; template class time_put_byname >; +#else + // Instantiate constructor taking __cxx11::string + template time_put_byname::time_put_byname(const string&, size_t); #endif _GLIBCXX_BEGIN_NAMESPACE_CXX11 template class time_get >; @@ -205,6 +208,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 // ctype + ctype_byname::ctype_byname(const string& __s, size_t __refs) + : ctype_byname(__s.c_str(), __refs) { } + #if ! _GLIBCXX_USE_CXX11_ABI inline template class __ctype_abstract_base; template class ctype_byname; @@ -214,6 +220,9 @@ _GLIBCXX_END_NAMESPACE_CXX11 #if ! _GLIBCXX_USE_CXX11_ABI inline template class __codecvt_abstract_base; template class codecvt_byname; +#else + // Instantiate constructor taking __cxx11::string + template codecvt_byname::codecvt_byname(const string&, size_t); #endif // collate diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc b/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc new file mode 100644 index 00000000000..8609b8034ea --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do link } + +#include +#include + +std::string s = "C"; + +template +struct facet : std::codecvt_byname +{ + facet() : std::codecvt_byname(s) { } +}; + +void +test01() +{ + facet c; + +#ifdef _GLIBCXX_USE_WCHAR_T + facet w; +#endif +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc b/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc new file mode 100644 index 00000000000..73b24dbdcbf --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do link } + +#include +#include + +std::string s = "C"; + +template +struct facet : std::collate_byname +{ + facet() : std::collate_byname(s) { } +}; + +void +test01() +{ + facet c; + +#ifdef _GLIBCXX_USE_WCHAR_T + facet w; +#endif +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/22_locale/ctype_byname/2.cc b/libstdc++-v3/testsuite/22_locale/ctype_byname/2.cc new file mode 100644 index 00000000000..f005384caa1 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/ctype_byname/2.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do link } + +#include +#include + +std::string s = "C"; + +template +struct facet : std::ctype_byname +{ + facet() : std::ctype_byname(s) { } +}; + +void +test01() +{ + facet c; + +#ifdef _GLIBCXX_USE_WCHAR_T + facet w; +#endif +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc new file mode 100644 index 00000000000..5902a92cb36 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do link } + +#include +#include + +std::string s = "C"; + +template +struct facet : std::messages_byname +{ + facet() : std::messages_byname(s) { } +}; + +void +test01() +{ + facet c; + +#ifdef _GLIBCXX_USE_WCHAR_T + facet w; +#endif +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc new file mode 100644 index 00000000000..a9bf44c3435 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do link } + +#include +#include + +std::string s = "C"; + +template +struct facet : std::moneypunct_byname +{ + facet() : std::moneypunct_byname(s) { } +}; + +void +test01() +{ + facet c0; + facet c1; + +#ifdef _GLIBCXX_USE_WCHAR_T + facet w0; + facet w1; +#endif +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc new file mode 100644 index 00000000000..2fca03faf33 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2015 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++11" } +// { dg-do link } + +#include +#include + +std::string s = "C"; + +template +struct facet : std::numpunct_byname +{ + facet() : std::numpunct_byname(s) { } +}; + +void +test01() +{ + facet c; + +#ifdef _GLIBCXX_USE_WCHAR_T + facet w; +#endif +} + +int +main() +{ + test01(); +} -- 2.30.2