Commit d39c6e16 authored by Davis King's avatar Davis King

I made some minor changes in a few places so that dlib compiles with the

clang compiler.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404122
parent 7d53ed0c
......@@ -716,6 +716,25 @@ namespace dlib
namespace bayes_node_utils
{
template <typename T>
unsigned long node_num_values (
const T& bn,
unsigned long n
)
{
// make sure requires clause is not broken
DLIB_ASSERT( n < bn.number_of_nodes(),
"\tvoid bayes_node_utils::node_num_values(bn, n)"
<< "\n\tInvalid arguments to this function"
<< "\n\tn: " << n
<< "\n\tbn.number_of_nodes(): " << bn.number_of_nodes()
);
return bn.node(n).data.table().num_values();
}
// ----------------------------------------------------------------------------------------
template <typename T>
void set_node_value (
T& bn,
......@@ -829,25 +848,6 @@ namespace dlib
bn.node(n).data.table().set_num_values(num);
}
// ----------------------------------------------------------------------------------------
template <typename T>
unsigned long node_num_values (
const T& bn,
unsigned long n
)
{
// make sure requires clause is not broken
DLIB_ASSERT( n < bn.number_of_nodes(),
"\tvoid bayes_node_utils::node_num_values(bn, n)"
<< "\n\tInvalid arguments to this function"
<< "\n\tn: " << n
<< "\n\tbn.number_of_nodes(): " << bn.number_of_nodes()
);
return bn.node(n).data.table().num_values();
}
// ----------------------------------------------------------------------------------------
template <typename T>
......
......@@ -108,7 +108,7 @@ namespace dlib
const domain& d
)
{
DLIB_CASSERT(operator[](d) != 0,
DLIB_CASSERT(this->operator[](d) != 0,
"\tvoid binary_search_tree::destroy"
<< "\n\tthe element must be in the tree for it to be removed"
<< "\n\tthis: " << this
......@@ -130,7 +130,7 @@ namespace dlib
range& r
)
{
DLIB_CASSERT(operator[](d) != 0 &&
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)),
......
......@@ -270,7 +270,7 @@ namespace dlib
{
try
{
const typename clp_base::option_type& opt = option(option_name);
const typename clp_base::option_type& opt = this->option(option_name);
const unsigned long number_of_arguments = opt.number_of_arguments();
const unsigned long count = opt.count();
for (unsigned long i = 0; i < number_of_arguments; ++i)
......@@ -348,7 +348,7 @@ namespace dlib
const char_type* (&arg_set)[length]
) const
{
const typename clp_base::option_type& opt = option(option_name);
const typename clp_base::option_type& opt = this->option(option_name);
const unsigned long number_of_arguments = opt.number_of_arguments();
const unsigned long count = opt.count();
for (unsigned long i = 0; i < number_of_arguments; ++i)
......@@ -433,12 +433,12 @@ namespace dlib
const char_type* (&sub_option_set)[length]
) const
{
if (option(parent_option).count() == 0)
if (this->option(parent_option).count() == 0)
{
size_t i = 0;
for (; i < length; ++i)
{
if (option(sub_option_set[i]).count() > 0)
if (this->option(sub_option_set[i]).count() > 0)
break;
}
if (i != length)
......@@ -533,7 +533,7 @@ namespace dlib
size_t i = 0;
for (; i < length; ++i)
{
if (option(option_set[i]).count() > 1)
if (this->option(option_set[i]).count() > 1)
break;
}
if (i != length)
......
......@@ -81,12 +81,12 @@ namespace dlib
{
// make sure requires clause is not broken
DLIB_CASSERT( (!is_in_domain(d)) &&
DLIB_CASSERT( (!this->is_in_domain(d)) &&
(reinterpret_cast<void*>(&d) != reinterpret_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): " << (is_in_domain(d) ? "true" : "false")
<< "\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)
......@@ -142,14 +142,14 @@ namespace dlib
// make sure requires clause is not broken
DLIB_CASSERT( (is_in_domain(d)) &&
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)),
"\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): " << (is_in_domain(d) ? "true" : "false")
<< "\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)
......@@ -174,7 +174,7 @@ namespace dlib
// make sure requires clause is not broken
DLIB_CASSERT( is_in_domain(d),
DLIB_CASSERT( this->is_in_domain(d),
"\tvoid hash_map::destroy"
<< "\n\tcan't remove something that isn't in the hash_map"
<< "\n\tthis: " << this
......@@ -197,7 +197,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( is_in_domain(d),
DLIB_CASSERT( this->is_in_domain(d),
"\trange& hash_map::operator[]"
<< "\n\td must be in the domain of the hash_map"
<< "\n\tthis: " << this
......
......@@ -68,7 +68,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( !is_member(item),
DLIB_CASSERT( !this->is_member(item),
"\tvoid hash_set::add"
<< "\n\titem being added must not already be in the hash_set"
<< "\n\tthis: " << this
......@@ -90,7 +90,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( is_member(item) &&
DLIB_CASSERT( this->is_member(item) &&
(reinterpret_cast<const void*>(&item) != reinterpret_cast<void*>(&item_copy)),
"\tvoid hash_set::remove"
<< "\n\titem should be in the hash_set if it's going to be removed"
......@@ -114,7 +114,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( is_member(item),
DLIB_CASSERT( this->is_member(item),
"\tvoid hash_set::destroy"
<< "\n\titem should be in the hash_set if it's going to be removed"
<< "\n\tthis: " << this
......
......@@ -87,7 +87,7 @@ namespace dlib
range& r
)
{
DLIB_CASSERT(operator[](d) != 0 &&
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)),
......
......@@ -81,12 +81,12 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( (!is_in_domain(d)) &&
DLIB_CASSERT( (!this->is_in_domain(d)) &&
(reinterpret_cast<void*>(&d) != reinterpret_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): " << (is_in_domain(d) ? "true" : "false")
<< "\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)
......@@ -136,14 +136,14 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( (is_in_domain(d)) &&
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)),
"\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): " << (is_in_domain(d) ? "true" : "false")
<< "\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)
......@@ -165,7 +165,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT(is_in_domain(d),
DLIB_CASSERT(this->is_in_domain(d),
"\tvoid map::destroy"
<< "\n\tcan't remove something that isn't in the map"
<< "\n\tthis: " << this
......@@ -187,7 +187,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( is_in_domain(d),
DLIB_CASSERT( this->is_in_domain(d),
"\trange& map::operator[]"
<< "\n\td must be in the domain of the map"
<< "\n\tthis: " << this
......@@ -208,7 +208,7 @@ namespace dlib
) const
{
// make sure requires clause is not broken
DLIB_CASSERT( is_in_domain(d),
DLIB_CASSERT( this->is_in_domain(d),
"\tconst range& map::operator[]"
<< "\n\td must be in the domain of the map"
<< "\n\tthis: " << this
......
......@@ -981,7 +981,7 @@ convergence:
const static long cost = 1;
const static long NR = (M::NC&&M::NR)? (tmax<M::NR,M::NC>::value) : (0);
const static long NR = ((M::NC!=0)&&(M::NR!=0))? (tmax<M::NR,M::NC>::value) : (0);
const static long NC = NR;
typedef typename M::type type;
typedef const type const_ret_type;
......
......@@ -1088,7 +1088,7 @@ namespace dlib
const M& m;
const static long cost = M::cost;
const static long NR = (M::NC&&M::NR)? (tmin<M::NR,M::NC>::value) : (0);
const static long NR = tmin<M::NR,M::NC>::value;
const static long NC = 1;
typedef typename M::type type;
typedef typename M::const_ret_type const_ret_type;
......
......@@ -66,7 +66,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( !is_member(item),
DLIB_CASSERT( !this->is_member(item),
"\tvoid set::add"
<< "\n\titem being added must not already be in the set"
<< "\n\tthis: " << this
......@@ -88,14 +88,14 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( is_member(item) &&
DLIB_CASSERT( this->is_member(item) &&
(reinterpret_cast<const void*>(&item) != reinterpret_cast<void*>(&item_copy)),
"\tvoid set::remove"
<< "\n\titem should be in the set if it's going to be removed"
<< "\n\tthis: " << this
<< "\n\t&item: " << &item
<< "\n\t&item_copy: " << &item_copy
<< "\n\tis_member(item): " << (is_member(item)?"true":"false")
<< "\n\tis_member(item): " << (this->is_member(item)?"true":"false")
);
// call the real function
......@@ -113,7 +113,7 @@ namespace dlib
)
{
// make sure requires clause is not broken
DLIB_CASSERT( is_member(item),
DLIB_CASSERT( this->is_member(item),
"\tvoid set::destroy"
<< "\n\titem should be in the set if it's going to be removed"
<< "\n\tthis: " << this
......
......@@ -17,6 +17,42 @@
namespace dlib
{
// ----------------------------------------------------------------------------------------
template <
typename charT,
typename traits,
typename alloc
>
inline const typename disable_if<is_same_type<charT,char>,std::string>::type narrow (
const std::basic_string<charT,traits,alloc>& str
)
{
std::string temp;
temp.reserve(str.size());
std::string::size_type i;
for (i = 0; i < str.size(); ++i)
{
if (zero_extend_cast<unsigned long>(str[i]) > 255)
temp += ' ';
else
temp += zero_extend_cast<char>(str[i]);
}
return temp;
}
template <
typename charT,
typename traits,
typename alloc
>
inline const typename enable_if<is_same_type<charT,char>,std::string>::type narrow (
const std::basic_string<charT,traits,alloc>& str
)
{
return str;
}
// ----------------------------------------------------------------------------------------
template <
......@@ -436,42 +472,6 @@ namespace dlib
const string_assign sa = string_assign();
// ----------------------------------------------------------------------------------------
template <
typename charT,
typename traits,
typename alloc
>
inline const typename disable_if<is_same_type<charT,char>,std::string>::type narrow (
const std::basic_string<charT,traits,alloc>& str
)
{
std::string temp;
temp.reserve(str.size());
std::string::size_type i;
for (i = 0; i < str.size(); ++i)
{
if (zero_extend_cast<unsigned long>(str[i]) > 255)
temp += ' ';
else
temp += zero_extend_cast<char>(str[i]);
}
return temp;
}
template <
typename charT,
typename traits,
typename alloc
>
inline const typename enable_if<is_same_type<charT,char>,std::string>::type narrow (
const std::basic_string<charT,traits,alloc>& str
)
{
return str;
}
// ----------------------------------------------------------------------------------------
template <
......
......@@ -179,7 +179,7 @@ namespace dlib
{
copy_to_df_helper(any_decision_function<sample_type, scalar_type>& target_) : target(target_) {}
mutable any_decision_function<sample_type, scalar_type>& target;
any_decision_function<sample_type, scalar_type>& target;
template <typename T>
void operator() (
......
......@@ -219,7 +219,7 @@ namespace dlib
{
copy_to_df_helper(any_decision_function<sample_type, scalar_type>& target_) : target(target_) {}
mutable any_decision_function<sample_type, scalar_type>& target;
any_decision_function<sample_type, scalar_type>& target;
template <typename T>
void operator() (
......
......@@ -16,7 +16,7 @@ namespace dlib
// ------------------------------------------------------------------------------
template <
typename K
typename Kern
>
class rbf_network_trainer
{
......@@ -28,7 +28,7 @@ namespace dlib
!*/
public:
typedef K kernel_type;
typedef Kern kernel_type;
typedef typename kernel_type::scalar_type scalar_type;
typedef typename kernel_type::sample_type sample_type;
typedef typename kernel_type::mem_manager_type mem_manager_type;
......
......@@ -103,7 +103,7 @@ namespace
matrix<type> a(rows,cols), temp, temp2, temp3;
for (int i = 0; i < 6; ++i)
for (int k = 0; k < 6; ++k)
{
for (long r= 0; r < a.nr(); ++r)
{
......
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