-//===---------------------------- system_error ----------------------------===//
+//===---------------------------- system_error ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_SYSTEM_SYSTEM_ERROR_H
-#define LLVM_SYSTEM_SYSTEM_ERROR_H
+#ifndef LLVM_SUPPORT_SYSTEM_ERROR_H
+#define LLVM_SUPPORT_SYSTEM_ERROR_H
+
+#include "llvm/Support/Compiler.h"
/*
system_error synopsis
const error_category& system_category();
template <class T> struct is_error_code_enum
- : public false_type {};
+ : public std::false_type {};
template <class T> struct is_error_condition_enum
- : public false_type {};
+ : public std::false_type {};
class error_code
{
wrong_protocol_type // EPROTOTYPE
};
-template <> struct is_error_condition_enum<errc> : true_type { }
+template <> struct is_error_condition_enum<errc> : std::true_type { }
error_code make_error_code(errc e);
error_condition make_error_condition(errc e);
*/
-#include "llvm/Config/config.h"
-#include "llvm/Support/type_traits.h"
+#include "llvm/Config/llvm-config.h"
#include <cerrno>
#include <string>
namespace llvm {
-template <class T, T v>
-struct integral_constant {
- typedef T value_type;
- static const value_type value = v;
- typedef integral_constant<T,v> type;
- operator value_type() { return value; }
-};
-
-typedef integral_constant<bool, true> true_type;
-typedef integral_constant<bool, false> false_type;
-
// is_error_code_enum
-template <class Tp> struct is_error_code_enum : public false_type {};
+template <class Tp> struct is_error_code_enum : public std::false_type {};
// is_error_condition_enum
-template <class Tp> struct is_error_condition_enum : public false_type {};
+template <class Tp> struct is_error_condition_enum : public std::false_type {};
// Some error codes are not present on all platforms, so we provide equivalents
// for them:
operator int() const {return v_;}
};
-template <> struct is_error_condition_enum<errc> : true_type { };
+template <> struct is_error_condition_enum<errc> : std::true_type { };
-template <> struct is_error_condition_enum<errc::_> : true_type { };
+template <> struct is_error_condition_enum<errc::_> : std::true_type { };
class error_condition;
class error_code;
public:
virtual ~error_category();
-private:
error_category();
- error_category(const error_category&);// = delete;
- error_category& operator=(const error_category&);// = delete;
+private:
+ error_category(const error_category&) LLVM_DELETED_FUNCTION;
+ error_category& operator=(const error_category&) LLVM_DELETED_FUNCTION;
public:
virtual const char* name() const = 0;
class _do_message : public error_category
{
public:
- virtual std::string message(int ev) const;
+ std::string message(int ev) const override;
};
const error_category& generic_category();
const error_category& system_category();
/// Get the error_category used for errno values from POSIX functions. This is
-/// the same as the system_category on POISIX systems, but is the same as the
+/// the same as the system_category on POSIX systems, but is the same as the
/// generic_category on Windows.
const error_category& posix_category();
: _val_(_val), _cat_(&_cat) {}
template <class E>
- error_condition(E _e, typename enable_if_c<
+ error_condition(E _e, typename std::enable_if<
is_error_condition_enum<E>::value
>::type* = 0)
{*this = make_error_condition(_e);}
}
template <class E>
- typename enable_if_c
- <
- is_error_condition_enum<E>::value,
- error_condition&
- >::type
- operator=(E _e)
- {*this = make_error_condition(_e); return *this;}
+ typename std::enable_if<is_error_condition_enum<E>::value,
+ error_condition &>::type
+ operator=(E _e) {
+ *this = make_error_condition(_e);
+ return *this;
+ }
void clear() {
_val_ = 0;
static void unspecified_bool_true() {}
operator unspecified_bool_type() const { // true if error
- return _val_ == 0 ? 0 : unspecified_bool_true;
+ return _val_ == 0 ? nullptr : unspecified_bool_true;
}
};
public:
error_code() : _val_(0), _cat_(&system_category()) {}
+ static error_code success() {
+ return error_code();
+ }
+
error_code(int _val, const error_category& _cat)
: _val_(_val), _cat_(&_cat) {}
template <class E>
- error_code(E _e, typename enable_if_c<
+ error_code(E _e, typename std::enable_if<
is_error_code_enum<E>::value
>::type* = 0) {
*this = make_error_code(_e);
}
template <class E>
- typename enable_if_c
- <
- is_error_code_enum<E>::value,
- error_code&
- >::type
- operator=(E _e)
- {*this = make_error_code(_e); return *this;}
+ typename std::enable_if<is_error_code_enum<E>::value, error_code &>::type
+ operator=(E _e) {
+ *this = make_error_code(_e);
+ return *this;
+ }
void clear() {
_val_ = 0;
static void unspecified_bool_true() {}
operator unspecified_bool_type() const { // true if error
- return _val_ == 0 ? 0 : unspecified_bool_true;
+ return _val_ == 0 ? nullptr : unspecified_bool_true;
}
};
};
-template <> struct is_error_code_enum<windows_error> : true_type { };
+template <> struct is_error_code_enum<windows_error> : std::true_type { };
-template <> struct is_error_code_enum<windows_error::_> : true_type { };
+template <> struct is_error_code_enum<windows_error::_> : std::true_type { };
inline error_code make_error_code(windows_error e) {
return error_code(static_cast<int>(e), system_category());