cstddef revision 227825
1// -*- C++ -*- 2//===--------------------------- cstddef ----------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#ifndef _LIBCPP_CSTDDEF 12#define _LIBCPP_CSTDDEF 13 14/* 15 cstddef synopsis 16 17Macros: 18 19 offsetof(type,member-designator) 20 NULL 21 22namespace std 23{ 24 25Types: 26 27 ptrdiff_t 28 size_t 29 max_align_t 30 nullptr_t 31 32} // std 33 34*/ 35 36#include <__config> 37 38#ifdef __GLIBC__ 39#define __need_NULL 40#define __need_ptrdiff_t 41#define __need_size_t 42#endif // __GLIBC__ 43 44#include <stddef.h> 45 46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 47#pragma GCC system_header 48#endif 49 50_LIBCPP_BEGIN_NAMESPACE_STD 51 52using ::ptrdiff_t; 53using ::size_t; 54 55typedef long double max_align_t; 56 57#ifdef _LIBCPP_HAS_NO_NULLPTR 58 59struct _LIBCPP_VISIBLE nullptr_t 60{ 61 void* _; 62 63 struct __nat {int __for_bool_;}; 64 65 _LIBCPP_ALWAYS_INLINE nullptr_t(int __nat::*) {} 66 67 _LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;} 68 69 template <class _Tp> 70 _LIBCPP_ALWAYS_INLINE 71 operator _Tp* () const {return 0;} 72 73 template <class _Tp, class _Up> 74 _LIBCPP_ALWAYS_INLINE 75 operator _Tp _Up::* () const {return 0;} 76 77 friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, nullptr_t) {return true;} 78 friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, nullptr_t) {return false;} 79 friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, nullptr_t) {return false;} 80 friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;} 81 friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;} 82 friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;} 83}; 84 85inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);} 86 87#define nullptr _VSTD::__get_nullptr_t() 88 89#endif // _LIBCPP_HAS_NO_NULLPTR 90 91_LIBCPP_END_NAMESPACE_STD 92 93#ifndef _LIBCPP_HAS_NO_NULLPTR 94 95namespace std 96{ 97 typedef decltype(nullptr) nullptr_t; 98} 99 100#endif // _LIBCPP_HAS_NO_NULLPTR 101 102#endif // _LIBCPP_CSTDDEF 103