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

Add "const" versions of -> and * operators. #142

Open
wants to merge 1 commit into
base: develop
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
2 changes: 2 additions & 0 deletions include/boost/iostreams/code_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ class code_converter
// Direct device access.

Device& operator*() { return detail::unwrap_direct(dev()); }
const Device& operator*() const { return detail::unwrap_direct(dev()); }
Device* operator->() { return &detail::unwrap_direct(dev()); }
const Device* operator->() const { return &detail::unwrap_direct(dev()); }
private:
template<typename T> // Used for forwarding.
void open_impl(const T& t BOOST_IOSTREAMS_CONVERTER_PARAMS())
Expand Down
2 changes: 2 additions & 0 deletions include/boost/iostreams/detail/adapter/concept_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class concept_adapter {
{ BOOST_STATIC_ASSERT(!is_std_io<T>::value); }

T& operator*() { return t_; }
const T& operator*() const { return t_; }
T* operator->() { return &t_; }
const T* operator->() const { return &t_; }

std::streamsize read(char_type* s, std::streamsize n)
{ return this->read(s, n, (basic_null_source<char_type>*) 0); }
Expand Down
1 change: 1 addition & 0 deletions include/boost/iostreams/detail/adapter/device_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class device_adapter {
public:
explicit device_adapter(param_type t) : t_(t) { }
T& component() { return t_; }
const T& component() const { return t_; }

void close()
{
Expand Down
2 changes: 2 additions & 0 deletions include/boost/iostreams/detail/adapter/direct_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class direct_adapter : private direct_adapter_base<Direct> {
// Direct device access.

Direct& operator*() { return d_; }
const Direct& operator*() const { return d_; }
Direct* operator->() { return &d_; }
const Direct* operator->() const { return &d_; }
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
private:
template<typename U>
Expand Down
1 change: 1 addition & 0 deletions include/boost/iostreams/detail/adapter/filter_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class filter_adapter {
public:
explicit filter_adapter(param_type t) : t_(t) { }
T& component() { return t_; }
const T& component() const { return t_; }

template<typename Device>
void close(Device& dev)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ struct stream : detail::stream_base<Device, Tr, Alloc> {
void set_auto_close(bool close) { this->member.set_auto_close(close); }
bool strict_sync() { return this->member.strict_sync(); }
Device& operator*() { return *this->member; }
const Device& operator*() const { return *this->member; }
Device* operator->() { return &*this->member; }
const Device* operator->() const { return &*this->member; }
private:
template<typename U0>
void open_impl(mpl::false_, const U0& u0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ class stream_buffer
}
#endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
T& operator*() { return *this->component(); }
const T& operator*() const { return *this->component(); }
T* operator->() { return this->component(); }
const T* operator->() const { return this->component(); }
private:
template<typename U0>
void open_impl(mpl::false_, const U0& u0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class direct_streambuf

// Declared in linked_streambuf.
T* component() { return storage_.get(); }
const T* component() const { return storage_.get(); }
protected:
BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type)
direct_streambuf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class indirect_streambuf

// Declared in linked_streambuf.
T* component() { return &*obj(); }
const T* component() const { return &*obj(); }
protected:
BOOST_IOSTREAMS_USING_PROTECTED_STREAMBUF_MEMBERS(base_type)

Expand Down Expand Up @@ -101,6 +102,7 @@ class indirect_streambuf
//----------Accessor functions--------------------------------------------//

wrapper& obj() { return *storage_; }
const wrapper& obj() const { return *storage_; }
streambuf_type* next() const { return next_; }
buffer_type& in() { return buffer_.first(); }
buffer_type& out() { return buffer_.second(); }
Expand Down
3 changes: 3 additions & 0 deletions include/boost/iostreams/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ struct stream : detail::stream_base<Device, Tr, Alloc> {
void set_auto_close(bool close) { this->member.set_auto_close(close); }
bool strict_sync() { return this->member.strict_sync(); }
Device& operator*() { return *this->member; }
const Device& operator*() const { return *this->member; }
Device* operator->() { return &*this->member; }
const Device* operator->() const { return &*this->member; }
Device* component() { return this->member.component(); }
const Device* component() const { return this->member.component(); }
private:
void open_impl(const Device& dev BOOST_IOSTREAMS_PUSH_PARAMS()) // For forwarding.
{
Expand Down
2 changes: 2 additions & 0 deletions include/boost/iostreams/stream_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ class stream_buffer
BOOST_IOSTREAMS_PUSH_PARAMS,
BOOST_IOSTREAMS_PUSH_ARGS )
T& operator*() { return *this->component(); }
const T& operator*() const { return *this->component(); }
T* operator->() { return this->component(); }
const T* operator->() const { return this->component(); }
private:
void open_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS())
{ // Used for forwarding.
Expand Down