Skip to content

Commit

Permalink
KDTree now compiles with MS VC 2005 with the 64 bit warnings turned o…
Browse files Browse the repository at this point in the history
…n (the cmake config sets this up).

The size type (size_t) has been switched to KDTREE_SIZE_T, a #define
that can be overridden.  By default it is size_t (the standard across
STL containers).

Signed-off-by: Paul Harris <[email protected]>
  • Loading branch information
paulharris committed Nov 13, 2008
1 parent dfdd353 commit 12f4e61
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 94 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
project (libkdtree CXX)
cmake_minimum_required (VERSION 2.6.0)

if (WIN32)

# Maximum warning level
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")

# Be strict about warnings... make them errors
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")

# Detect 64-bit portability issues
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wp64")

else (WIN32)

# Maximum warning level
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")

endif (WIN32)

include_directories (${PROJECT_SOURCE_DIR})

add_subdirectory(examples)
6 changes: 4 additions & 2 deletions examples/test_hayne.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#define KDTREE_SIZE_T unsigned int
#include <kdtree++/kdtree.hpp>

#include <vector>
#include <limits>
#include <iostream>
Expand All @@ -10,7 +12,7 @@ struct duplet
{
typedef int value_type;

inline value_type operator[](size_t const N) const { return d[N]; }
inline value_type operator[](int const N) const { return d[N]; }

inline bool operator==(duplet const& other) const
{
Expand Down Expand Up @@ -68,7 +70,7 @@ int main()

dupl_tree_test.optimise();

int elements;
size_t elements;

while (vDuplets.size() > 0) //delete all duplets from tree which are in the vector
{
Expand Down
8 changes: 4 additions & 4 deletions examples/test_kdtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
struct triplet {
typedef int value_type;

inline value_type operator[](size_t const N) const { return d[N]; }
inline value_type operator[](KDTREE_SIZE_T const N) const { return d[N]; }

value_type d[3];
};
Expand All @@ -24,10 +24,10 @@ std::ostream& operator<<(std::ostream& out, triplet const& T)
return out << '(' << T.d[0] << ',' << T.d[1] << ',' << T.d[2] << ')';
}

inline double tac( triplet t, int k ) { return t[k]; }
inline double tac( triplet t, KDTREE_SIZE_T k ) { return t[k]; }


typedef KDTree::KDTree<3, triplet, std::pointer_to_binary_function<triplet,int,double> > tree_type;
typedef KDTree::KDTree<3, triplet, std::pointer_to_binary_function<triplet,KDTREE_SIZE_T,double> > tree_type;

int main()
{
Expand Down Expand Up @@ -77,7 +77,7 @@ int main()
std::vector<triplet> v;
unsigned int const RANGE = 3;

size_t count = t.count_within_range(s, RANGE);
KDTREE_SIZE_T count = t.count_within_range(s, RANGE);
std::cout << "counted " << count
<< " nodes within range " << RANGE << " of " << s << ".\n";
t.find_within_range(s, RANGE, std::back_inserter(v));
Expand Down
2 changes: 1 addition & 1 deletion kdtree++/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <cstddef>

#include <kdtree++/node.hpp>
#include "node.hpp"

namespace KDTree
{
Expand Down
3 changes: 2 additions & 1 deletion kdtree++/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define INCLUDE_KDTREE_ACCESSOR_HPP

#include <cstddef>
#include "kdtree_size_t.hpp"

namespace KDTree
{
Expand All @@ -18,7 +19,7 @@ namespace KDTree
typedef typename _Val::value_type result_type;

result_type
operator()(_Val const& V, size_t const N) const
operator()(_Val const& V, KDTREE_SIZE_T const N) const
{
return V[N];
}
Expand Down
2 changes: 1 addition & 1 deletion kdtree++/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace KDTree
}
}

template <size_t const __K, typename _Val, typename _Acc,
template <KDTREE_SIZE_T const __K, typename _Val, typename _Acc,
typename _Dist, typename _Cmp, typename _Alloc>
friend class KDTree;
};
Expand Down
Loading

0 comments on commit 12f4e61

Please sign in to comment.