This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] libstdc++/64650 add bad_optional_access default constructor


The Library Fundamentals TS says
std::experimental::bad_optional_access should have a default
constructor, but we only support construction from strings.

This removes the unused and non-standard std::string constructor and
adds the required default constructor.

Tested x86_64-linux, *not* committed.
commit a3012f752e52870c9d257187a3c43e9fc2873892
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sun Jan 18 16:52:07 2015 +0000

    	PR libstdc++/64650
    	* include/experimental/optional (bad_optional_access): Add default
    	constructor.
    	* testsuite/experimental/optional/requirements.cc: Test for default
    	constructor.

diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional
index 206b945..811235b 100644
--- a/libstdc++-v3/include/experimental/optional
+++ b/libstdc++-v3/include/experimental/optional
@@ -110,9 +110,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   class bad_optional_access : public logic_error
   {
   public:
-    // XXX Should not be inline
-    explicit bad_optional_access(const string& __arg) : logic_error(__arg) { }
+    bad_optional_access() : logic_error("bad optional access") { }
 
+    // XXX This constructor is non-standard. Should not be inline
     explicit bad_optional_access(const char* __arg) : logic_error(__arg) { }
 
     virtual ~bad_optional_access() noexcept = default;
diff --git a/libstdc++-v3/testsuite/experimental/optional/requirements.cc b/libstdc++-v3/testsuite/experimental/optional/requirements.cc
index e83975a..531b6ca 100644
--- a/libstdc++-v3/testsuite/experimental/optional/requirements.cc
+++ b/libstdc++-v3/testsuite/experimental/optional/requirements.cc
@@ -23,6 +23,9 @@
 
 #include <tuple>
 
+using std::experimental::bad_optional_access;
+static_assert( std::is_default_constructible<bad_optional_access>::value, "" );
+
 struct trivially_destructible
 {
   trivially_destructible() = delete;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]