Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
Closed
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
7 changes: 4 additions & 3 deletions thrust/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,9 @@ template <typename T> __host__ __device__ complex<T> atanh(const complex<T>& z);
* \param os The output stream.
* \param z The \p complex number to output.
*/
template<typename ValueType,class charT, class traits>
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const complex<ValueType>& z);
template<typename ValueType, typename charT, typename traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const complex<ValueType>& z);

/*! Reads a \p complex number from an input stream.
* The recognized formats are:
Expand All @@ -555,7 +556,7 @@ std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>&
* \param is The input stream.
* \param z The \p complex number to set.
*/
template<typename ValueType, typename charT, class traits>
template<typename ValueType, typename charT, typename traits>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is, complex<ValueType>& z);

Expand Down
9 changes: 0 additions & 9 deletions thrust/detail/device_ptr.inl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include <thrust/device_ptr.h>
#include <thrust/device_reference.h>
#include <iostream>

#include <thrust/detail/type_traits.h>
#include <thrust/iterator/iterator_traits.h>

Expand All @@ -41,13 +39,6 @@ template<typename T>
return ptr;
} // end device_pointer_cast()

// output to ostream
template<class E, class T, class Y>
std::basic_ostream<E, T> &operator<<(std::basic_ostream<E, T> &os, const device_ptr<Y> &p)
{
return os << p.get();
} // end operator<<()


namespace detail
{
Expand Down
9 changes: 9 additions & 0 deletions thrust/detail/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/detail/type_traits.h>
#include <thrust/detail/reference_forward_declaration.h>
#include <ostream>


namespace thrust
{
Expand Down Expand Up @@ -178,6 +180,13 @@ template<typename Element, typename Tag, typename Reference, typename Derived>
Element *get() const;
}; // end pointer

// Output stream operator
template<typename Element, typename Tag, typename Reference, typename Derived,
typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, let's not provide this feature for pointer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already exists for thrust::device_ptr, this simply promotes it to thrust::pointer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, if it already exists, that's fine.

const pointer<Element, Tag, Reference, Derived> &p);

} // end thrust

#include <thrust/detail/pointer.inl>
Expand Down
7 changes: 7 additions & 0 deletions thrust/detail/pointer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ template<typename Element, typename Tag, typename Reference, typename Derived>
return super_t::base();
} // end pointer::get

template<typename Element, typename Tag, typename Reference, typename Derived,
typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os,
const pointer<Element, Tag, Reference, Derived> &p) {
return os << p.get();
}

namespace detail
{
Expand Down
9 changes: 8 additions & 1 deletion thrust/detail/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <thrust/detail/type_traits.h>
#include <thrust/detail/use_default.h>
#include <thrust/detail/reference_forward_declaration.h>
#include <ostream>


namespace thrust
Expand Down Expand Up @@ -160,7 +161,13 @@ template<typename Element, typename Pointer, typename Derived>
value_type convert_to_value_type(System *system) const;
}; // end reference


// Output stream operator
template<typename Element, typename Pointer, typename Derived,
typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os,
const reference<Element, Pointer, Derived> &y);

} // end thrust

#include <thrust/detail/reference.inl>
Expand Down
11 changes: 9 additions & 2 deletions thrust/detail/reference.inl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ template<typename Element, typename Pointer, typename Derived>
return static_cast<derived_type&>(*this);
} // end reference::operator^=()


} // end thrust
template<typename Element, typename Pointer, typename Derived,
typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os,
const reference<Element, Pointer, Derived> &y) {
typedef typename reference<Element, Pointer, Derived>::value_type value_type;
return os << static_cast<value_type>(y);
} // end operator<<()

} // end thrust
16 changes: 10 additions & 6 deletions thrust/device_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <thrust/detail/config.h>
#include <thrust/memory.h>
#include <ostream>

namespace thrust
{
Expand Down Expand Up @@ -121,14 +120,19 @@ template<typename T>
#endif // end doxygen-only members
}; // end device_ptr

/*! This operator outputs the value of a \p device_ptr's raw pointer to a \p std::basic_ostream.
// declare these methods for the purpose of Doxygenating them
// they actually are defined for a derived-from class
#if 0
/*! Writes to an output stream the value of a \p device_ptr's raw pointer.
*
* \param os The std::basic_ostream of interest.
* \param p The device_ptr of interest.
* \param os The output stream.
* \param p The \p device_ptr to output.
* \return os.
*/
template<class E, class T, class Y>
inline std::basic_ostream<E, T> &operator<<(std::basic_ostream<E, T> &os, const device_ptr<Y> &p);
template<typename T, typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os, const device_ptr<T> &p);
#endif

/*! \}
*/
Expand Down
14 changes: 14 additions & 0 deletions thrust/device_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,20 @@ template<typename T>
__host__ __device__
void swap(device_reference<T> &x, device_reference<T> &y);

// declare these methods for the purpose of Doxygenating them
// they actually are defined for a derived-from class
#if 0
/*! Writes to an output stream the value of a \p device_reference.
*
* \param os The output stream.
* \param y The \p device_reference to output.
* \return os.
*/
template<typename T, typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os, const device_reference<T> &y);
#endif

/*! \}
*/

Expand Down