aboutsummaryrefslogtreecommitdiff
path: root/butl/fdstream.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-08-02 15:45:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-08-02 15:45:37 +0200
commit614d23129684f96ff0c5d77ee9c5a29be1f44272 (patch)
treee53c1f43232686ea557231721303431e6156c8e9 /butl/fdstream.cxx
parentc4d5840039ef12cdedb6476044e9917eec481b09 (diff)
Reimplement throw_ios_failure() to keep Clang 3.5 happy
Diffstat (limited to 'butl/fdstream.cxx')
-rw-r--r--butl/fdstream.cxx30
1 files changed, 13 insertions, 17 deletions
diff --git a/butl/fdstream.cxx b/butl/fdstream.cxx
index e2095ba..f761e7b 100644
--- a/butl/fdstream.cxx
+++ b/butl/fdstream.cxx
@@ -34,30 +34,26 @@ namespace butl
{
// throw_ios_failure
//
- template <bool = is_base_of<system_error, ios_base::failure>::value>
- struct throw_ios
+ template <bool v>
+ static inline void
+ throw_ios_failure (error_code e, typename enable_if<v, const char*>::type m)
{
- static void impl (error_code e, const char* m) {
- throw ios_base::failure (m, e);}
- };
-
- template <>
- struct throw_ios<false>
- {
- static void impl (error_code, const char* m) {throw ios_base::failure (m);}
- };
+ throw ios_base::failure (m, e);
+ }
- inline void
- throw_ios_failure (int ev)
+ template <bool v>
+ static inline void
+ throw_ios_failure (error_code, typename enable_if<!v, const char*>::type m)
{
- error_code ec (ev, system_category ());
- throw_ios<>::impl (ec, ec.message ().c_str ());
+ throw ios_base::failure (m);
}
inline void
- throw_ios_failure (int ev, const char* m)
+ throw_ios_failure (int ev, const char* m = nullptr)
{
- throw_ios<>::impl (error_code (ev, system_category ()), m);
+ error_code ec (ev, system_category ());
+ throw_ios_failure<is_base_of<system_error, ios_base::failure>::value> (
+ ec, m != nullptr ? m : ec.message ().c_str ());
}
// fdbuf