Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement std::is_integral #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 60 additions & 55 deletions src/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -28,61 +28,66 @@
#pragma GCC visibility push(default)

namespace std{

struct _UCXXEXPORT __true_type{};
struct _UCXXEXPORT __false_type{};

template <class I> class _UCXXEXPORT __is_integer{
public:
typedef __false_type value;
};

template <> class _UCXXEXPORT __is_integer <unsigned int>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <signed int>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <short unsigned int>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <short signed int>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <char>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <signed char>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <unsigned char>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <long unsigned int>{
public:
typedef __true_type value;
};

template <> class _UCXXEXPORT __is_integer <long signed int>{
public:
typedef __true_type value;
};


template<typename _Tp, _Tp __v>
struct integral_constant
{
static constexpr _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant<_Tp, __v> type;
constexpr operator value_type() const { return value; }
};

template<typename _Tp, _Tp __v>
constexpr _Tp integral_constant<_Tp, __v>::value;

typedef integral_constant<bool, true> true_type;

typedef integral_constant<bool, false> false_type;

template <class I>
class _UCXXEXPORT __is_integral_helper
: public false_type { };

template <>
class _UCXXEXPORT __is_integral_helper <unsigned int>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <signed int>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <short unsigned int>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <short signed int>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <char>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <signed char>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <unsigned char>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <long unsigned int>
: public true_type { };

template <>
class _UCXXEXPORT __is_integral_helper <long signed int>
: public true_type { };

template<typename _Tp>
struct is_integral
: public __is_integral_helper<_Tp>::type
{ };

}

Expand Down
6 changes: 3 additions & 3 deletions src/vector
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ namespace std{
}

template <class InputIterator>
inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __true_type)
inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, true_type)
{
_insert_fill(position, first, last);
}

template <class InputIterator>
inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, __false_type)
inline void _dispatch_insert(iterator position, InputIterator first, InputIterator last, false_type)
{
_insert_from_iterator(position, first, last);
}
Expand All @@ -308,7 +308,7 @@ namespace std{
}

template <class InputIterator> inline void insert(iterator position, InputIterator first, InputIterator last){
typedef typename __is_integer<InputIterator>::value __some_type;
typedef typename is_integral<InputIterator>::value __some_type;
_dispatch_insert(position, first, last, __some_type());
}

Expand Down