Skip to content

Commit a9c7a5a

Browse files
committed
Use ASIO_ASSERT in place of BOOST_ASSERT.
1 parent fe56b3d commit a9c7a5a

File tree

6 files changed

+54
-15
lines changed

6 files changed

+54
-15
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// detail/assert.hpp
3+
// ~~~~~~~~~~~~~~~~~
4+
//
5+
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6+
//
7+
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8+
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9+
//
10+
11+
#ifndef ASIO_DETAIL_ASSERT_HPP
12+
#define ASIO_DETAIL_ASSERT_HPP
13+
14+
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15+
# pragma once
16+
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17+
18+
#include "asio/detail/config.hpp"
19+
20+
#if defined(ASIO_HAS_BOOST_ASSERT)
21+
# include <boost/assert.hpp>
22+
#else // defined(ASIO_HAS_BOOST_ASSERT)
23+
# include <cassert>
24+
#endif // defined(ASIO_HAS_BOOST_ASSERT)
25+
26+
#if defined(ASIO_HAS_BOOST_ASSERT)
27+
# define ASIO_ASSERT(expr) BOOST_ASSERT(expr)
28+
#else // defined(ASIO_HAS_BOOST_ASSERT)
29+
# define ASIO_ASSERT(expr) assert(expr)
30+
#endif // defined(ASIO_HAS_BOOST_ASSERT)
31+
32+
#endif // ASIO_DETAIL_ASSERT_HPP

asio/include/asio/detail/buffered_stream_storage.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "asio/detail/config.hpp"
1919
#include "asio/buffer.hpp"
20-
#include <boost/assert.hpp>
20+
#include "asio/detail/assert.hpp"
2121
#include <cstddef>
2222
#include <cstring>
2323
#include <vector>
@@ -78,7 +78,7 @@ class buffered_stream_storage
7878
// Resize the buffer to the specified length.
7979
void resize(size_type length)
8080
{
81-
BOOST_ASSERT(length <= capacity());
81+
ASIO_ASSERT(length <= capacity());
8282
if (begin_offset_ + length <= capacity())
8383
{
8484
end_offset_ = begin_offset_ + length;
@@ -101,7 +101,7 @@ class buffered_stream_storage
101101
// Consume multiple bytes from the beginning of the buffer.
102102
void consume(size_type count)
103103
{
104-
BOOST_ASSERT(begin_offset_ + count <= end_offset_);
104+
ASIO_ASSERT(begin_offset_ + count <= end_offset_);
105105
begin_offset_ += count;
106106
if (empty())
107107
clear();

asio/include/asio/detail/config.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,4 +440,11 @@
440440
// Helper to prevent macro expansion.
441441
#define ASIO_PREVENT_MACRO_SUBSTITUTION
442442

443+
// Boost assert macro.
444+
#if !defined(ASIO_DISABLE_BOOST_ASSERT)
445+
# if !defined(ASIO_HAS_BOOST_ASSERT)
446+
# define ASIO_HAS_BOOST_ASSERT 1
447+
# endif // !defined(ASIO_HAS_BOOST_ASSERT)
448+
#endif // !defined(ASIO_DISABLE_BOOST_ASSERT)
449+
443450
#endif // ASIO_DETAIL_CONFIG_HPP

asio/include/asio/detail/hash_map.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
1717

1818
#include "asio/detail/config.hpp"
19-
#include <boost/assert.hpp>
2019
#include <list>
2120
#include <utility>
21+
#include "asio/detail/assert.hpp"
2222
#include "asio/detail/noncopyable.hpp"
2323

2424
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
@@ -179,7 +179,7 @@ class hash_map
179179
// Erase an entry from the map.
180180
void erase(iterator it)
181181
{
182-
BOOST_ASSERT(it != values_.end());
182+
ASIO_ASSERT(it != values_.end());
183183

184184
size_t bucket = calculate_hash_value(it->first) % num_buckets_;
185185
bool is_first = (it == buckets_[bucket].first);

asio/include/asio/detail/posix_event.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#if defined(ASIO_HAS_PTHREADS)
2121

22-
#include <boost/assert.hpp>
2322
#include <pthread.h>
23+
#include "asio/detail/assert.hpp"
2424
#include "asio/detail/noncopyable.hpp"
2525

2626
#include "asio/detail/push_options.hpp"
@@ -45,7 +45,7 @@ class posix_event
4545
template <typename Lock>
4646
void signal(Lock& lock)
4747
{
48-
BOOST_ASSERT(lock.locked());
48+
ASIO_ASSERT(lock.locked());
4949
(void)lock;
5050
signalled_ = true;
5151
::pthread_cond_signal(&cond_); // Ignore EINVAL.
@@ -55,7 +55,7 @@ class posix_event
5555
template <typename Lock>
5656
void signal_and_unlock(Lock& lock)
5757
{
58-
BOOST_ASSERT(lock.locked());
58+
ASIO_ASSERT(lock.locked());
5959
signalled_ = true;
6060
lock.unlock();
6161
::pthread_cond_signal(&cond_); // Ignore EINVAL.
@@ -65,7 +65,7 @@ class posix_event
6565
template <typename Lock>
6666
void clear(Lock& lock)
6767
{
68-
BOOST_ASSERT(lock.locked());
68+
ASIO_ASSERT(lock.locked());
6969
(void)lock;
7070
signalled_ = false;
7171
}
@@ -74,7 +74,7 @@ class posix_event
7474
template <typename Lock>
7575
void wait(Lock& lock)
7676
{
77-
BOOST_ASSERT(lock.locked());
77+
ASIO_ASSERT(lock.locked());
7878
while (!signalled_)
7979
::pthread_cond_wait(&cond_, &lock.mutex().mutex_); // Ignore EINVAL.
8080
}

asio/include/asio/detail/win_event.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#if defined(ASIO_WINDOWS)
2121

22-
#include <boost/assert.hpp>
22+
#include "asio/detail/assert.hpp"
2323
#include "asio/detail/noncopyable.hpp"
2424
#include "asio/detail/socket_types.hpp"
2525

@@ -45,7 +45,7 @@ class win_event
4545
template <typename Lock>
4646
void signal(Lock& lock)
4747
{
48-
BOOST_ASSERT(lock.locked());
48+
ASIO_ASSERT(lock.locked());
4949
(void)lock;
5050
::SetEvent(event_);
5151
}
@@ -54,7 +54,7 @@ class win_event
5454
template <typename Lock>
5555
void signal_and_unlock(Lock& lock)
5656
{
57-
BOOST_ASSERT(lock.locked());
57+
ASIO_ASSERT(lock.locked());
5858
lock.unlock();
5959
::SetEvent(event_);
6060
}
@@ -63,7 +63,7 @@ class win_event
6363
template <typename Lock>
6464
void clear(Lock& lock)
6565
{
66-
BOOST_ASSERT(lock.locked());
66+
ASIO_ASSERT(lock.locked());
6767
(void)lock;
6868
::ResetEvent(event_);
6969
}
@@ -72,7 +72,7 @@ class win_event
7272
template <typename Lock>
7373
void wait(Lock& lock)
7474
{
75-
BOOST_ASSERT(lock.locked());
75+
ASIO_ASSERT(lock.locked());
7676
lock.unlock();
7777
::WaitForSingleObject(event_, INFINITE);
7878
lock.lock();

0 commit comments

Comments
 (0)