diff --git a/sprout/iterator/const_iterator_cast.hpp b/sprout/iterator/const_iterator_cast.hpp index e988dd65..90dd0bd7 100644 --- a/sprout/iterator/const_iterator_cast.hpp +++ b/sprout/iterator/const_iterator_cast.hpp @@ -85,7 +85,7 @@ namespace sprout { {}; template struct is_const_iterator_cast_convertible - : public sprout::is_same::type, typename std::remove_const::type> + : public sprout::is_same::type, typename std::remove_cv::type> {}; } // namespace sprout @@ -133,4 +133,54 @@ namespace sprout { } } // namespace sprout +// +// note: +// const_iterator_cast is an adaptable function for interconversion +// with iterator and const_iterator. +// If you want to adapt a user-defined iterator class to const_iterator_cast: +// - Specialize sprout::is_const_iterator_cast_convertible. +// - Overload const_iterator_conversion as to be lookup in the ADL. +// +// example: +// #include +// #include +// #include +// #include +// /* Mylib::Iterator is an user-defined iterator class*/ +// namespace Mylib { +// template +// struct Iterator { +// T* p; +// typedef T* pointer; +// /* definition iterator interface... */ +// }; +// } +// /* const_iterator_cast adapt for Mylib::Iterator */ +// namespace sprout { +// template +// struct is_const_iterator_cast_convertible< +// Mylib::Iterator, +// Mylib::Iterator +// > +// : public sprout::is_same< +// typename std::remove_cv::type, +// typename std::remove_cv::type +// > +// {}; +// } +// namespace Mylib { +// template +// inline SPROUT_CONSTEXPR typename std::enable_if< +// sprout::is_const_iterator_cast_convertible, To>::value, +// To +// >::type +// const_iterator_conversion(Iterator const& it) { +// return To{const_cast(it.p)}; +// } +// } +// /* test const_iterator_cast with Mylib::Iterator */ +// constexpr Mylib::Iterator it{0}; +// static_assert(sprout::const_iterator_cast >(it).p == 0, ""); +// + #endif // #ifndef SPROUT_ITERATOR_CONST_ITERATOR_CAST_HPP diff --git a/sprout/iterator/const_reference_cast.hpp b/sprout/iterator/const_reference_cast.hpp index fc7d3eca..101c887c 100644 --- a/sprout/iterator/const_reference_cast.hpp +++ b/sprout/iterator/const_reference_cast.hpp @@ -189,4 +189,54 @@ namespace sprout { } } // namespace sprout +// +// note: +// const_reference_cast is an adaptable function for interconversion +// with reference and const_reference. +// If you want to adapt a user-defined reference proxy class to const_reference_cast: +// - Specialize sprout::is_const_reference_cast_convertible. +// - Overload const_reference_conversion as to be lookup in the ADL. +// +// example: +// #include +// #include +// #include +// #include +// /* Mylib::Reference is an user-defined reference proxy class*/ +// namespace Mylib { +// template +// struct Reference { +// T* p; +// typedef T* pointer; +// /* definition reference proxy interface... */ +// }; +// } +// /* const_reference_cast adapt for Mylib::Reference */ +// namespace sprout { +// template +// struct is_const_reference_cast_convertible< +// Mylib::Reference, +// Mylib::Reference +// > +// : public sprout::is_same< +// typename std::remove_cv::type, +// typename std::remove_cv::type +// > +// {}; +// } +// namespace Mylib { +// template +// inline SPROUT_CONSTEXPR typename std::enable_if< +// sprout::is_const_reference_cast_convertible, To>::value, +// To +// >::type +// const_reference_conversion(Reference const& it) { +// return To{const_cast(it.p)}; +// } +// } +// /* test const_reference_cast with Mylib::Reference */ +// constexpr Mylib::Reference it{0}; +// static_assert(sprout::const_reference_cast >(it).p == 0, ""); +// + #endif // #ifndef SPROUT_ITERATOR_CONST_REFERENCE_CAST_HPP diff --git a/sprout/iterator/index_iterator.hpp b/sprout/iterator/index_iterator.hpp index 53f22066..d4267848 100644 --- a/sprout/iterator/index_iterator.hpp +++ b/sprout/iterator/index_iterator.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -294,7 +295,7 @@ namespace sprout { // template struct is_const_iterator_cast_convertible, sprout::index_iterator > - : public std::is_same::type, typename std::decay::type> + : public sprout::is_same::type, typename std::decay::type> {}; // // const_iterator_conversion diff --git a/sprout/type_traits/is_copy_assignable.hpp b/sprout/type_traits/is_copy_assignable.hpp index a85b5425..06f0bd24 100644 --- a/sprout/type_traits/is_copy_assignable.hpp +++ b/sprout/type_traits/is_copy_assignable.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace sprout { // @@ -23,7 +24,7 @@ namespace sprout { {}; template struct is_copy_assignable_impl - : public std::is_assignable + : public sprout::is_assignable {}; } // namespace detail template diff --git a/sprout/type_traits/is_copy_constructible.hpp b/sprout/type_traits/is_copy_constructible.hpp index 625b2f13..538aa272 100644 --- a/sprout/type_traits/is_copy_constructible.hpp +++ b/sprout/type_traits/is_copy_constructible.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace sprout { // @@ -23,7 +24,7 @@ namespace sprout { {}; template struct is_copy_constructible_impl - : public std::is_constructible + : public sprout::is_constructible {}; } // namespace detail template diff --git a/sprout/type_traits/is_move_assignable.hpp b/sprout/type_traits/is_move_assignable.hpp index 7605720f..ea0b1652 100644 --- a/sprout/type_traits/is_move_assignable.hpp +++ b/sprout/type_traits/is_move_assignable.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace sprout { // @@ -23,7 +24,7 @@ namespace sprout { {}; template struct is_move_assignable_impl - : public std::is_assignable + : public sprout::is_assignable {}; } // namespace detail template diff --git a/sprout/type_traits/is_move_constructible.hpp b/sprout/type_traits/is_move_constructible.hpp index 35be19b9..5677540f 100644 --- a/sprout/type_traits/is_move_constructible.hpp +++ b/sprout/type_traits/is_move_constructible.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace sprout { // @@ -23,7 +24,7 @@ namespace sprout { {}; template struct is_move_constructible_impl - : public std::is_constructible + : public sprout::is_constructible {}; } // namespace detail template