X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2Fsystem_error.h;h=af812069b9fef0f9ab5264fd914b689749e707c4;hb=5eb301740c4ee5d978535caa917cc004733a7fca;hp=9d4a8b721e39236e05673518b845bc5c35afc8f7;hpb=44c1bc14570e77630b5e6711ed42886aad848086;p=oota-llvm.git diff --git a/include/llvm/Support/system_error.h b/include/llvm/Support/system_error.h index 9d4a8b721e3..af812069b9f 100644 --- a/include/llvm/Support/system_error.h +++ b/include/llvm/Support/system_error.h @@ -1,4 +1,4 @@ -//===---------------------------- system_error ----------------------------===// +//===---------------------------- system_error ------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -222,7 +222,7 @@ template <> struct hash; */ -#include "llvm/Config/config.h" +#include "llvm/Config/llvm-config.h" #include "llvm/Support/type_traits.h" #include #include @@ -470,17 +470,6 @@ template <> struct hash; namespace llvm { -template -struct integral_constant { - typedef T value_type; - static const value_type value = v; - typedef integral_constant type; - operator value_type() { return value; } -}; - -typedef integral_constant true_type; -typedef integral_constant false_type; - // is_error_code_enum template struct is_error_code_enum : public false_type {}; @@ -668,6 +657,11 @@ public: 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 POSIX systems, but is the same as the +/// generic_category on Windows. +const error_category& posix_category(); + class error_condition { int _val_; @@ -708,8 +702,12 @@ public: const error_category& category() const {return *_cat_;} std::string message() const; - // explicit - operator bool() const {return _val_ != 0;} + typedef void (*unspecified_bool_type)(); + static void unspecified_bool_true() {} + + operator unspecified_bool_type() const { // true if error + return _val_ == 0 ? 0 : unspecified_bool_true; + } }; inline error_condition make_error_condition(errc _e) { @@ -729,6 +727,10 @@ class error_code { 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) {} @@ -767,8 +769,12 @@ public: std::string message() const; - // explicit - operator bool() const {return _val_ != 0;} + typedef void (*unspecified_bool_type)(); + static void unspecified_bool_true() {} + + operator unspecified_bool_type() const { // true if error + return _val_ == 0 ? 0 : unspecified_bool_true; + } }; inline error_code make_error_code(errc _e) {