Commit 2b4dc97c authored by Davis King's avatar Davis King

All I did in this change was rename a bunch of reinterpret_casts

to static_casts whenever it was possilbe to do so.
parent 5a166a6d
......@@ -86,7 +86,7 @@ namespace dlib
range& r
)
{
DLIB_CASSERT( reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r),
DLIB_CASSERT( static_cast<const void*>(&d) != static_cast<void*>(&r),
"\tvoid binary_search_tree::add"
<< "\n\tyou can't call add() and give the same object to both parameters."
<< "\n\tthis: " << this
......@@ -131,9 +131,9 @@ namespace dlib
)
{
DLIB_CASSERT(this->operator[](d) != 0 &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&d_copy)) &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r)) &&
(reinterpret_cast<const void*>(&r) != reinterpret_cast<void*>(&d_copy)),
(static_cast<const void*>(&d) != static_cast<void*>(&d_copy)) &&
(static_cast<const void*>(&d) != static_cast<void*>(&r)) &&
(static_cast<const void*>(&r) != static_cast<void*>(&d_copy)),
"\tvoid binary_search_tree::remove"
<< "\n\tthe element must be in the tree for it to be removed"
<< "\n\tthis: " << this
......@@ -157,7 +157,7 @@ namespace dlib
)
{
DLIB_CASSERT(this->size() != 0 &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r)),
(static_cast<const void*>(&d) != static_cast<void*>(&r)),
"\tvoid binary_search_tree::remove_any"
<< "\n\ttree must not be empty if something is going to be removed"
<< "\n\tthis: " << this
......
......@@ -284,10 +284,10 @@ namespace dlib
) const { return options.current_element_valid(); }
const cmd_line_parser_option<charT>& element (
) const { return *reinterpret_cast<cmd_line_parser_option<charT>*>(options.element().value()); }
) const { return *static_cast<cmd_line_parser_option<charT>*>(options.element().value()); }
cmd_line_parser_option<charT>& element (
) { return *reinterpret_cast<cmd_line_parser_option<charT>*>(options.element().value()); }
) { return *static_cast<cmd_line_parser_option<charT>*>(options.element().value()); }
bool move_next (
) const { return options.move_next(); }
......@@ -356,7 +356,7 @@ namespace dlib
options.reset();
while (options.move_next())
{
delete reinterpret_cast<option_t*>(options.element().value());
delete static_cast<option_t*>(options.element().value());
}
}
......@@ -380,7 +380,7 @@ namespace dlib
options.reset();
while (options.move_next())
{
delete reinterpret_cast<option_t*>(options.element().value());
delete static_cast<option_t*>(options.element().value());
}
options.clear();
reset();
......@@ -413,7 +413,7 @@ namespace dlib
options.reset();
while (options.move_next())
{
reinterpret_cast<option_t*>(options.element().value())->clear();
static_cast<option_t*>(options.element().value())->clear();
}
options.reset();
}
......@@ -469,7 +469,7 @@ namespace dlib
}
option_t* o = reinterpret_cast<option_t*>(options[temp]);
option_t* o = static_cast<option_t*>(options[temp]);
// check the number of arguments after this option and make sure
// it is correct
......@@ -560,7 +560,7 @@ namespace dlib
throw cmd_line_parse_error(EINVALID_OPTION,name);
}
option_t* o = reinterpret_cast<option_t*>(options[name]);
option_t* o = static_cast<option_t*>(options[name]);
// if there are chars immediately following this option
int delta = 0;
......@@ -629,7 +629,7 @@ namespace dlib
options.reset();
while (options.move_next())
{
reinterpret_cast<option_t*>(options.element().value())->clear();
static_cast<option_t*>(options.element().value())->clear();
}
options.reset();
......@@ -708,7 +708,7 @@ namespace dlib
const string_type& name
) const
{
return *reinterpret_cast<cmd_line_parser_option<charT>*>(options[name]);
return *static_cast<cmd_line_parser_option<charT>*>(options[name]);
}
// ----------------------------------------------------------------------------------------
......
......@@ -263,7 +263,7 @@ namespace dlib
block_table.reset();
while (block_table.move_next())
{
delete reinterpret_cast<config_reader_kernel_1*>(block_table.element().value());
delete static_cast<config_reader_kernel_1*>(block_table.element().value());
}
block_table.clear();
key_table.clear();
......@@ -565,7 +565,7 @@ namespace dlib
throw config_reader_access_error(name,"");
}
return *reinterpret_cast<config_reader_kernel_1*>(block_table[name]);
return *static_cast<config_reader_kernel_1*>(block_table[name]);
}
// ----------------------------------------------------------------------------------------
......
......@@ -293,7 +293,7 @@ namespace dlib
block_table.reset();
while (block_table.move_next())
{
delete reinterpret_cast<config_reader_thread_safe_1*>(block_table.element().value());
delete static_cast<config_reader_thread_safe_1*>(block_table.element().value());
}
block_table.clear();
}
......@@ -345,7 +345,7 @@ namespace dlib
throw config_reader_access_error(name,"");
}
return *reinterpret_cast<config_reader_thread_safe_1*>(block_table[name]);
return *static_cast<config_reader_thread_safe_1*>(block_table[name]);
}
// ----------------------------------------------------------------------------------------
......@@ -431,7 +431,7 @@ namespace dlib
block_table.reset();
while (block_table.move_next())
{
delete reinterpret_cast<config_reader_thread_safe_1*>(block_table.element().value());
delete static_cast<config_reader_thread_safe_1*>(block_table.element().value());
}
block_table.clear();
......
......@@ -305,7 +305,7 @@ namespace dlib
static void error_box_helper(void* param)
{
ebh_param& p = *reinterpret_cast<ebh_param*>(param);
ebh_param& p = *static_cast<ebh_param*>(param);
#ifdef UNICODE
MessageBox (NULL, convert_mbstring_to_wstring(p.text).c_str(),
convert_mbstring_to_wstring(p.title).c_str(), MB_OK|MB_ICONERROR|MB_SYSTEMMODAL
......
......@@ -80,7 +80,7 @@ namespace dlib
int i
)
{
drawable* d = reinterpret_cast<drawable*>(p);
drawable* d = static_cast<drawable*>(p);
if (widget_set.is_member(d))
{
d->on_user_event(i);
......
......@@ -2695,7 +2695,7 @@ namespace dlib
// The point of this extra event_handler stuff is to allow the user
// to end the program from within the callback. So we want to destroy the
// window *before* we call their callback.
box_win& w = *reinterpret_cast<box_win*>(param);
box_win& w = *static_cast<box_win*>(param);
w.close_window();
any_function<void()> event_handler(w.event_handler);
delete &w;
......
......@@ -82,14 +82,14 @@ namespace dlib
// make sure requires clause is not broken
DLIB_CASSERT( (!this->is_in_domain(d)) &&
(reinterpret_cast<void*>(&d) != reinterpret_cast<void*>(&r)),
(static_cast<void*>(&d) != static_cast<void*>(&r)),
"\tvoid hash_map::add"
<< "\n\tdomain element being added must not already be in the hash_map"
<< "\n\tand d and r must not be the same variable"
<< "\n\tis_in_domain(d): " << (this->is_in_domain(d) ? "true" : "false")
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<void*>(&d)
<< "\n\t&r: " << reinterpret_cast<void*>(&r)
<< "\n\t&d: " << static_cast<void*>(&d)
<< "\n\t&r: " << static_cast<void*>(&r)
);
......@@ -112,14 +112,14 @@ namespace dlib
// make sure requires clause is not broken
DLIB_CASSERT( (this->size() > 0) &&
(reinterpret_cast<void*>(&d) != reinterpret_cast<void*>(&r)),
(static_cast<void*>(&d) != static_cast<void*>(&r)),
"\tvoid hash_map::remove_any"
<< "\n\tsize() must be greater than zero if something is going to be removed"
<< "\n\tand d and r must not be the same variable."
<< "\n\tsize(): " << this->size()
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<void*>(&d)
<< "\n\t&r: " << reinterpret_cast<void*>(&r)
<< "\n\t&d: " << static_cast<void*>(&d)
<< "\n\t&r: " << static_cast<void*>(&r)
);
......@@ -143,17 +143,17 @@ namespace dlib
// make sure requires clause is not broken
DLIB_CASSERT( (this->is_in_domain(d)) &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r)) &&
(reinterpret_cast<void*>(&r) != reinterpret_cast<void*>(&d_copy)) &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&d_copy)),
(static_cast<const void*>(&d) != static_cast<void*>(&r)) &&
(static_cast<void*>(&r) != static_cast<void*>(&d_copy)) &&
(static_cast<const void*>(&d) != static_cast<void*>(&d_copy)),
"\tvoid hash_map::remove"
<< "\n\tcan't remove something that isn't in the hash_map or if the paremeters"
<< "\n\tare actually the same variable. Either way can't remove."
<< "\n\tis_in_domain(d): " << (this->is_in_domain(d) ? "true" : "false")
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<const void*>(&d)
<< "\n\t&r: " << reinterpret_cast<void*>(&r)
<< "\n\t&d_copy: " << reinterpret_cast<void*>(&d_copy)
<< "\n\t&d: " << static_cast<const void*>(&d)
<< "\n\t&r: " << static_cast<void*>(&r)
<< "\n\t&d_copy: " << static_cast<void*>(&d_copy)
);
......@@ -178,7 +178,7 @@ namespace dlib
"\tvoid hash_map::destroy"
<< "\n\tcan't remove something that isn't in the hash_map"
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<const void*>(&d)
<< "\n\t&d: " << static_cast<const void*>(&d)
);
......
......@@ -91,7 +91,7 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_CASSERT( this->is_member(item) &&
(reinterpret_cast<const void*>(&item) != reinterpret_cast<void*>(&item_copy)),
(static_cast<const void*>(&item) != static_cast<void*>(&item_copy)),
"\tvoid hash_set::remove"
<< "\n\titem should be in the hash_set if it's going to be removed"
<< "\n\tthis: " << this
......
......@@ -88,9 +88,9 @@ namespace dlib
)
{
DLIB_CASSERT(this->operator[](d) != 0 &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&d_copy)) &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r)) &&
(reinterpret_cast<const void*>(&r) != reinterpret_cast<void*>(&d_copy)),
(static_cast<const void*>(&d) != static_cast<void*>(&d_copy)) &&
(static_cast<const void*>(&d) != static_cast<void*>(&r)) &&
(static_cast<const void*>(&r) != static_cast<void*>(&d_copy)),
"\tvoid binary_search_tree::remove"
<< "\n\tthe element must be in the table for it to be removed"
<< "\n\tthis: " << this
......@@ -113,7 +113,7 @@ namespace dlib
range& r
)
{
DLIB_CASSERT( reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r),
DLIB_CASSERT( static_cast<const void*>(&d) != static_cast<void*>(&r),
"\tvoid binary_search_tree::add"
<< "\n\tyou can't call add() and give the same object to both arguments."
<< "\n\tthis: " << this
......@@ -157,7 +157,7 @@ namespace dlib
)
{
DLIB_CASSERT(this->size() != 0 &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r)),
(static_cast<const void*>(&d) != static_cast<void*>(&r)),
"\tvoid hash_table::remove_any"
<< "\n\ttable must not be empty if something is going to be removed"
<< "\n\tthis: " << this
......
......@@ -238,7 +238,7 @@ namespace dlib
void* param
)
{
linker_kernel_1& p = *reinterpret_cast<linker_kernel_1*>(param);
linker_kernel_1& p = *static_cast<linker_kernel_1*>(param);
p.cons_mutex.lock();
// if the connections are gone for whatever reason then return
......
......@@ -82,14 +82,14 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_CASSERT( (!this->is_in_domain(d)) &&
(reinterpret_cast<void*>(&d) != reinterpret_cast<void*>(&r)),
(static_cast<void*>(&d) != static_cast<void*>(&r)),
"\tvoid map::add"
<< "\n\tdomain element being added must not already be in the map"
<< "\n\tand d and r must not be the same variable"
<< "\n\tis_in_domain(d): " << (this->is_in_domain(d) ? "true" : "false")
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<void*>(&d)
<< "\n\t&r: " << reinterpret_cast<void*>(&r)
<< "\n\t&d: " << static_cast<void*>(&d)
<< "\n\t&r: " << static_cast<void*>(&r)
);
// call the real function
......@@ -109,14 +109,14 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_CASSERT( (this->size() > 0) &&
(reinterpret_cast<void*>(&d) != reinterpret_cast<void*>(&r)),
(static_cast<void*>(&d) != static_cast<void*>(&r)),
"\tvoid map::remove_any"
<< "\n\tsize() must be greater than zero if something is going to be removed"
<< "\n\tand d and r must not be the same variable."
<< "\n\tsize(): " << this->size()
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<void*>(&d)
<< "\n\t&r: " << reinterpret_cast<void*>(&r)
<< "\n\t&d: " << static_cast<void*>(&d)
<< "\n\t&r: " << static_cast<void*>(&r)
);
// call the real function
......@@ -137,17 +137,17 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_CASSERT( (this->is_in_domain(d)) &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&r)) &&
(reinterpret_cast<void*>(&r) != reinterpret_cast<void*>(&d_copy)) &&
(reinterpret_cast<const void*>(&d) != reinterpret_cast<void*>(&d_copy)),
(static_cast<const void*>(&d) != static_cast<void*>(&r)) &&
(static_cast<void*>(&r) != static_cast<void*>(&d_copy)) &&
(static_cast<const void*>(&d) != static_cast<void*>(&d_copy)),
"\tvoid map::remove"
<< "\n\tcan't remove something that isn't in the map or if the paremeters actually"
<< "\n\tare the same variable. Either way can't remove."
<< "\n\tis_in_domain(d): " << (this->is_in_domain(d) ? "true" : "false")
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<const void*>(&d)
<< "\n\t&r: " << reinterpret_cast<void*>(&r)
<< "\n\t&d_copy: " << reinterpret_cast<void*>(&d_copy)
<< "\n\t&d: " << static_cast<const void*>(&d)
<< "\n\t&r: " << static_cast<void*>(&r)
<< "\n\t&d_copy: " << static_cast<void*>(&d_copy)
);
// call the real function
......@@ -169,7 +169,7 @@ namespace dlib
"\tvoid map::destroy"
<< "\n\tcan't remove something that isn't in the map"
<< "\n\tthis: " << this
<< "\n\t&d: " << reinterpret_cast<const void*>(&d)
<< "\n\t&d: " << static_cast<const void*>(&d)
);
// call the real function
......
......@@ -82,7 +82,7 @@ namespace dlib
{
node* temp = next;
next = next->next;
::operator delete ( reinterpret_cast<void*>(temp));
::operator delete ( static_cast<void*>(temp));
}
}
......@@ -119,7 +119,7 @@ namespace dlib
try
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(temp))T();
new (static_cast<void*>(temp))T();
}
catch (...)
{
......@@ -133,16 +133,16 @@ namespace dlib
}
else
{
temp = reinterpret_cast<T*>(::operator new(sizeof(node)));
temp = static_cast<T*>(::operator new(sizeof(node)));
try
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(temp))T();
new (static_cast<void*>(temp))T();
}
catch (...)
{
// construction of the new object threw so delete the block of memory
::operator delete ( reinterpret_cast<void*>(temp));
::operator delete ( static_cast<void*>(temp));
throw;
}
}
......@@ -160,7 +160,7 @@ namespace dlib
if (pool_size >= max_pool_size)
{
::operator delete ( reinterpret_cast<void*>(item));
::operator delete ( static_cast<void*>(item));
return;
}
......
......@@ -96,7 +96,7 @@ namespace dlib
chunk_node* temp = first_chunk;
first_chunk = first_chunk->next;
// delete the memory chunk
::operator delete ( reinterpret_cast<void*>(temp->chunk));
::operator delete ( static_cast<void*>(temp->chunk));
// delete the chunk_node
delete temp;
}
......@@ -135,7 +135,7 @@ namespace dlib
try
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(temp))T();
new (static_cast<void*>(temp))T();
}
catch (...)
{
......@@ -149,7 +149,7 @@ namespace dlib
{
// the linked list is empty so we need to allocate some more memory
node* block = 0;
block = reinterpret_cast<node*>(::operator new (sizeof(node)*chunk_size));
block = static_cast<node*>(::operator new (sizeof(node)*chunk_size));
// the first part of this block can be our new object
temp = reinterpret_cast<T*>(block);
......@@ -157,12 +157,12 @@ namespace dlib
try
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(temp))T();
new (static_cast<void*>(temp))T();
}
catch (...)
{
// construction of the new object threw so delete the block of memory
::operator delete ( reinterpret_cast<void*>(block));
::operator delete ( static_cast<void*>(block));
throw;
}
......@@ -172,7 +172,7 @@ namespace dlib
catch (...)
{
temp->~T();
::operator delete ( reinterpret_cast<void*>(block));
::operator delete ( static_cast<void*>(block));
throw;
}
......
......@@ -109,7 +109,7 @@ namespace dlib
chunk_node* temp = first_chunk;
first_chunk = first_chunk->next;
// delete the memory chunk
::operator delete ( reinterpret_cast<void*>(temp->chunk));
::operator delete ( static_cast<void*>(temp->chunk));
// delete the chunk_node
delete temp;
}
......@@ -152,7 +152,7 @@ namespace dlib
}
else
{
temp = reinterpret_cast<char*>(::operator new(block_size));
temp = static_cast<char*>(::operator new(block_size));
}
reinterpret_cast<size_t*>(temp)[0] = block_size;
......@@ -204,7 +204,7 @@ namespace dlib
try
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(temp))T();
new (static_cast<void*>(temp))T();
}
catch (...)
{
......@@ -217,7 +217,7 @@ namespace dlib
else
{
// the linked list is empty so we need to allocate some more memory
node* block = reinterpret_cast<node*>(::operator new (sizeof(node)*chunk_size));
node* block = static_cast<node*>(::operator new (sizeof(node)*chunk_size));
// the first part of this block can be our new object
temp = reinterpret_cast<T*>(block);
......@@ -225,12 +225,12 @@ namespace dlib
try
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(temp))T();
new (static_cast<void*>(temp))T();
}
catch (...)
{
// construction of the new object threw so delete the block of memory
::operator delete ( reinterpret_cast<void*>(block));
::operator delete ( static_cast<void*>(block));
throw;
}
......@@ -240,7 +240,7 @@ namespace dlib
catch (...)
{
temp->~T();
::operator delete ( reinterpret_cast<void*>(block));
::operator delete ( static_cast<void*>(block));
throw;
}
......@@ -310,7 +310,7 @@ namespace dlib
for (i = 0; i < size; ++i)
{
// construct this new T object with placement new.
new (reinterpret_cast<void*>(array+i))T();
new (static_cast<void*>(array+i))T();
}
}
catch (...)
......
......@@ -661,7 +661,7 @@ namespace dlib
void* item
)
{
param& p = *reinterpret_cast<param*>(item);
param& p = *static_cast<param*>(item);
p.server.on_connect(p.new_connection);
......
......@@ -89,7 +89,7 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_CASSERT( this->is_member(item) &&
(reinterpret_cast<const void*>(&item) != reinterpret_cast<void*>(&item_copy)),
(static_cast<const void*>(&item) != static_cast<void*>(&item_copy)),
"\tvoid set::remove"
<< "\n\titem should be in the set if it's going to be removed"
<< "\n\tthis: " << this
......
......@@ -58,7 +58,7 @@ namespace
)
{
add_running_thread();
pipe& p = *reinterpret_cast<pipe*>(param);
pipe& p = *static_cast<pipe*>(param);
try
{
......@@ -95,7 +95,7 @@ namespace
)
{
add_running_thread();
pipe& p = *reinterpret_cast<pipe*>(param);
pipe& p = *static_cast<pipe*>(param);
try
{
......@@ -131,7 +131,7 @@ namespace
)
{
add_running_thread();
pipe& p = *reinterpret_cast<pipe*>(param);
pipe& p = *static_cast<pipe*>(param);
try
{
......
......@@ -37,7 +37,7 @@ namespace
)
{
listener& list = *reinterpret_cast<listener*>(param);
listener& list = *static_cast<listener*>(param);
connection* con;
list.accept(con);
......
......@@ -20,7 +20,7 @@ namespace dlib
void* obj
)
{
T* o = reinterpret_cast<T*>(obj);
T* o = static_cast<T*>(obj);
(o->*funct)();
}
......
......@@ -31,7 +31,7 @@ namespace dlib
void* param
)
{
info* alloc_p = reinterpret_cast<info*>(param);
info* alloc_p = static_cast<info*>(param);
info p = *alloc_p;
delete alloc_p;
......
......@@ -29,7 +29,7 @@ namespace dlib
void* param
)
{
info* alloc_p = reinterpret_cast<info*>(param);
info* alloc_p = static_cast<info*>(param);
info p = *alloc_p;
delete alloc_p;
......
......@@ -201,7 +201,7 @@ namespace dlib
)
{
// get a reference to the calling threader object
threader& self = *reinterpret_cast<threader*>(object);
threader& self = *static_cast<threader*>(object);
{
......
......@@ -195,7 +195,7 @@ namespace dlib
- returns a non-const reference to the T object
!*/
{
return *reinterpret_cast<T*>(mem.get());
return *static_cast<T*>(mem.get());
}
template <typename T>
......@@ -208,7 +208,7 @@ namespace dlib
- returns a const reference to the T object
!*/
{
return *reinterpret_cast<const T*>(mem.get());
return *static_cast<const T*>(mem.get());
}
template <typename T>
......@@ -518,7 +518,7 @@ namespace dlib
{
validate_type<T>();
construct<T>();
return *reinterpret_cast<T*>(mem.get());
return *static_cast<T*>(mem.get());
}
template <typename T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment