15 #ifndef INCG_IRIS_IUTEST_STDLIB_HPP_54D4BEEE_7B6B_4AF4_B1F6_138560480D55_ 
   16 #define INCG_IRIS_IUTEST_STDLIB_HPP_54D4BEEE_7B6B_4AF4_B1F6_138560480D55_ 
   28 #if !defined(IUTEST_USING_BEGIN_END) 
   29 #  if IUTEST_HAS_STD_BEGIN_END 
   30 #    define IUTEST_USING_BEGIN_END()    \ 
   31     using ::std::begin; using ::std::end 
   33 #    define IUTEST_USING_BEGIN_END()    \ 
   34     using ::iutest::detail::cxx::begin; using ::iutest::detail::cxx::end 
   43 #if IUTEST_HAS_STD_BEGIN_END 
   50 template<
typename T> 
typename T::iterator begin(T& x) { 
return x.begin(); }
 
   51 template<
typename T> 
typename T::iterator end  (T& x) { 
return x.end(); }
 
   53 template<
typename T> 
typename T::const_iterator begin(
const T& x) { 
return x.begin(); }
 
   54 template<
typename T> 
typename T::const_iterator end  (
const T& x) { 
return x.end(); }
 
   56 #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING) 
   57 template<
typename T, 
size_t SIZE> T* begin(T (&x)[SIZE]) { 
return &x[0]; }
 
   58 template<
typename T, 
size_t SIZE> T* end  (T (&x)[SIZE]) { 
return begin(x) + SIZE; }
 
   60 template<
typename T, 
size_t SIZE> 
const T* begin(
const T (&x)[SIZE]) { 
return &x[0]; }
 
   61 template<
typename T, 
size_t SIZE> 
const T* end  (
const T (&x)[SIZE]) { 
return begin(x) + SIZE; }
 
   72 #if !IUTEST_USE_EXTERNAL_STD_TUPLE && !IUTEST_USE_EXTERNAL_TR1_TUPLE 
   73 #  if   IUTEST_HAS_STD_TUPLE 
   75 #  elif IUTEST_HAS_TR1_TUPLE 
   76 #    if (defined(__GNUC__) && (__GNUC__ >= 4)) 
   89 #if   IUTEST_HAS_STD_TUPLE 
   90 namespace alias = ::std;
 
   91 #elif IUTEST_HAS_TR1_TUPLE 
   92 namespace alias = ::std::tr1;
 
   96 using alias::tuple_element;
 
   97 using alias::make_tuple;
 
  100 template<
typename T>
struct tuple_size : 
public alias::tuple_size<T> {};
 
  101 template<
typename T>
struct tuple_size<const T> : 
public alias::tuple_size<T> {};
 
  102 template<
typename T>
struct tuple_size<volatile T> : 
public alias::tuple_size<T>{};
 
  103 template<
typename T>
struct tuple_size<const volatile T> : 
public alias::tuple_size<T>{};
 
  108 template<
typename T, 
typename F, 
int Begin>
 
  109 struct tuple_foreach_impl
 
  111     template<
int N, 
int I>
 
  114         static void do_something(T& t, F fn)
 
  123         static void do_something(T&, F) {}
 
  126     static void do_something(T& t, F fn)
 
  132 template<
typename T, 
typename U>
 
  133 struct tuple_cast_copy_impl
 
  135     template<
int N, 
int I>
 
  138         static void copy(T& dst, 
const U& src)
 
  140             get<I>(dst) = 
static_cast<typename tuple_element<I, T>::type
>(get<I>(src));
 
  147         static void copy(T&, 
const U&) {}
 
  150     static void copy(T& dst, 
const U& src)
 
  158 template<
int I, 
typename tuple_t, 
typename F>
 
  159 void tuple_foreach(tuple_t& t, F& fn)
 
  161     detail::tuple_foreach_impl<tuple_t, F&, I>::do_something(t, fn);
 
  163 template<
typename tuple_t, 
typename F>
 
  164 void tuple_foreach(tuple_t& t, F& fn)
 
  166     tuple_foreach<0>(t, fn);
 
  168 template<
int I, 
typename tuple_t, 
typename F>
 
  169 void tuple_foreach(tuple_t& t, 
const F& fn)
 
  171     detail::tuple_foreach_impl<tuple_t, const F&, I>::do_something(t, fn);
 
  173 template<
typename tuple_t, 
typename F>
 
  174 void tuple_foreach(tuple_t& t, 
const F& fn)
 
  176     tuple_foreach<0>(t, fn);
 
  178 template<
typename T, 
typename U>
 
  179 void tuple_cast_copy(T& dst, 
const U& src)
 
  181     detail::tuple_cast_copy_impl<T, U>::copy(dst, src);
 
  187 using tuples::tuple_size;
 
  188 using tuples::tuple_element;
 
  189 using tuples::tuple_foreach;
 
  190 using tuples::make_tuple;
 
  207 #if IUTEST_HAS_EXCEPTIONS 
  211 class bad_optional_access : 
public ::std::exception {};
 
  220     typedef T value_type;
 
  224     explicit optional(
const T& rhs) : m_init(
true), m_value(rhs) {}
 
  226     explicit optional(
const U& rhs) : m_init(
true), m_value(T(rhs)) {}
 
  230     optional& operator = (
const T& rhs) { m_init = 
true; m_value = rhs; 
return *
this; }
 
  231     operator bool ()
 const { 
return has_value(); }
 
  232     const T& operator * ()
 const { 
return value(); }
 
  233     T& operator * () { 
return value(); }
 
  234     const T* operator -> ()
 const { 
return ptr(); }
 
  235     T* operator -> () { 
return ptr(); }
 
  238     bool has_value()
 const { 
return m_init; }
 
  239     const T* ptr()
 const { 
return &m_value; }
 
  240     T* ptr() { 
return &m_value; }
 
  241     const T& value()
 const 
  243 #if IUTEST_HAS_EXCEPTIONS 
  252 #if IUTEST_HAS_EXCEPTIONS 
  260     T value_or(
const U& v)
 const 
  273 inline bool uncaught_exception()
 
  275 #if IUTEST_HAS_CXX1Z && (!defined(IUTEST_LIBSTDCXX_VERSION) || (IUTEST_LIBSTDCXX_VERSION >= 60000)) 
  276     return ::std::uncaught_exceptions() > 0;
 
  278     return ::std::uncaught_exception();
 
  290 namespace type_t_helper
 
  296 template<
size_t SIZE>
 
  297 struct type_fit_t {};
 
  303 #if defined(INT8_MIN) 
  305     typedef uint8_t             UInt;
 
  308     typedef unsigned char       UInt;
 
  316 #if defined(INT16_MIN) 
  318     typedef uint16_t            UInt;
 
  321     typedef unsigned short      UInt;
 
  329 #if defined(INT32_MIN) 
  331     typedef uint32_t            UInt;
 
  333 #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) 
  335     template<
typename T, 
typename F, 
bool b>
 
  336     struct impl { 
typedef T type; };
 
  337     template<
typename T, 
typename F>
 
  338     struct impl<T, F, false> { 
typedef F type; };
 
  341     typedef impl<long, int
 
  342         , 
sizeof(int) != 4 && 
sizeof(
long) == 4>::type Int;
 
  343     typedef impl<
unsigned long, 
unsigned int
 
  344         , 
sizeof(int) != 4 && 
sizeof(
long) == 4>::type UInt;
 
  347     typedef unsigned int        UInt;
 
  356 #if defined(INT64_MIN) 
  358     typedef uint64_t            UInt;
 
  360 #if defined(_MSC_VER) 
  362     typedef unsigned __int64    UInt;
 
  364     typedef long long           Int;
 
  365     typedef unsigned long long  UInt;
 
  372 struct type_fit_t<16>
 
  374 #if IUTEST_HAS_INT128 
  375 #if defined(_MSC_VER) 
  376     typedef __int128            Int;
 
  377     typedef unsigned __int128   UInt;
 
  379     typedef __int128_t  Int;
 
  380     typedef __uint128_t UInt;
 
  388 template<
size_t SIZE>
 
  389 struct type_least_t {};
 
  393 struct type_least_t<1>
 
  395 #if defined(INT_LEAST8_MIN) 
  396     typedef int_least8_t        Int;
 
  397     typedef uint_least8_t       UInt;
 
  400     typedef unsigned char       UInt;
 
  406 struct type_least_t<2>
 
  408 #if defined(INT_LEAST16_MIN) 
  409     typedef int_least16_t       Int;
 
  410     typedef uint_least16_t      UInt;
 
  413     typedef unsigned short      UInt;
 
  419 struct type_least_t<4>
 
  421 #if defined(INT_LEAST32_MIN) 
  422     typedef int_least32_t       Int;
 
  423     typedef uint_least32_t      UInt;
 
  426     typedef unsigned int        UInt;
 
  432 struct type_least_t<8>
 
  434 #if defined(INT_LEAST64_MIN) 
  435     typedef int_least64_t       Int;
 
  436     typedef uint_least64_t      UInt;
 
  438 #if defined(_MSC_VER) 
  440     typedef unsigned __int64    UInt;
 
  442     typedef long long           Int;
 
  443     typedef unsigned long long  UInt;
 
  450 struct type_least_t<16> : 
public type_fit_t<16>
 
  454 template<
bool B, 
typename T, 
typename U>
 
  457     template<
bool X, 
typename TMP>
 
  458     struct impl { 
typedef T type; };
 
  459     template<
typename TMP>
 
  460     struct impl<false, TMP> { 
typedef U type; };
 
  462     typedef typename impl<B, void>::type type;
 
  465 template<
size_t SIZE>
 
  466 struct type_fit_t_select
 
  468     typedef typename conditional<(SIZE & (SIZE - 1)) == 0, type_fit_t<SIZE>
 
  469         , 
typename conditional<(SIZE > 8), type_fit_t<16>
 
  470             , 
typename conditional<(SIZE > 4), type_fit_t<8>
 
  471                 , 
typename conditional<(SIZE > 2), type_fit_t<4>
 
  472                     , 
typename conditional<(SIZE > 1), type_fit_t<2>
 
  481 template<
size_t SIZE>
 
  482 struct type_least_t_select
 
  484     typedef typename conditional<(SIZE & (SIZE - 1)) == 0, type_least_t<SIZE>
 
  485         , 
typename conditional<(SIZE > 8), type_least_t<16>
 
  486             , 
typename conditional<(SIZE > 4), type_least_t<8>
 
  487                 , 
typename conditional<(SIZE > 2), type_least_t<4>
 
  488                     , 
typename conditional<(SIZE > 1), type_least_t<2>
 
  502 template<
size_t SIZE>
 
  503 struct type_fit_t : 
public type_t_helper::type_fit_t_select<SIZE>::type {};
 
  508 template<
size_t SIZE>
 
  509 struct type_least_t : 
public type_t_helper::type_least_t_select<SIZE>::type {};
 
  517 inline int iu_mbtowc(
wchar_t* dst, 
const char* src, 
size_t size)
 
  519 #if defined(IUTEST_OS_LINUX_ANDROID) || defined(IUTEST_OS_WINDOWS_MOBILE) 
  521     IUTEST_UNUSED_VAR(dst);
 
  522     IUTEST_UNUSED_VAR(src);
 
  523     IUTEST_UNUSED_VAR(size);
 
  526     return mbtowc(dst, src, size);
 
  533     return (::std::numeric_limits<T>::min)();
 
  539     return (::std::numeric_limits<T>::max)();
 
any_cast の失敗例外
Definition: iutest_stdlib.hpp:212
Definition: iutest_stdlib.hpp:215
Definition: iutest_stdlib.hpp:219
#define IUTEST_CXX_NOEXCEPT_SPEC
noexcept specification definition
Definition: iutest_compiler.hpp:811
iutest root namespace
Definition: iutest_charcode.hpp:33
Definition: iutest_stdlib.hpp:138
Definition: iutest_stdlib.hpp:114
Definition: iutest_stdlib.hpp:101