]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/13860 (Poor error messages on invalid template parameters for basic_f...
authorJonathan Wakely <jwakely@redhat.com>
Thu, 8 May 2014 18:30:14 +0000 (19:30 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 8 May 2014 18:30:14 +0000 (19:30 +0100)
PR libstdc++/13860
* include/std/fstream (basic_filebuf): Enforce requirements on traits.

From-SVN: r210231

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/fstream

index 20079f9b240b54c78064c9eecc5f752e7537553d..9ee95da828030da7a0dce604edfbdedb6eeb53eb 100644 (file)
@@ -11,6 +11,9 @@
        (swap(basic_streambuf&)): Define for C++11.
        * testsuite/27_io/basic_streambuf/cons/57394.cc: New.
 
+       PR libstdc++/13860
+       * include/std/fstream (basic_filebuf): Enforce requirements on traits.
+
 2014-05-08  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * acinclude.m4 ([GLIBCXX_ENABLE_C99]): Avoid -Wwrite-strings warning.
index 17ccac62868cf474e555d164e6da80cc1636812a..51db21b525c7ea046e32e7580c5b903db5638d60 100644 (file)
@@ -71,6 +71,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _CharT, typename _Traits>
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
     {
+#if __cplusplus >= 201103L
+      template<typename _Tp>
+       using __chk_state = __and_<is_copy_assignable<_Tp>,
+                                  is_copy_constructible<_Tp>,
+                                  is_default_constructible<_Tp>>;
+
+      static_assert(__chk_state<typename _Traits::state_type>::value,
+                   "state_type must be CopyAssignable, CopyConstructible"
+                   " and DefaultConstructible");
+
+      static_assert(is_same<typename _Traits::pos_type,
+                           fpos<typename _Traits::state_type>>::value,
+                   "pos_type must be fpos<state_type>");
+#endif
     public:
       // Types:
       typedef _CharT                                   char_type;