Skip to content

Commit

Permalink
Fix linux build.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Dec 26, 2020
1 parent b09fa9b commit 6b22972
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
19 changes: 15 additions & 4 deletions include/tesseract/genericvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,20 @@ namespace tesseract {
// sort that works.
template <typename T>
class GenericVector : public std::vector<T> {
using base = std::vector<T>;
public:
using std::vector<T>::vector;

using base::begin;
using base::end;
using base::data;
using base::capacity;
using base::reserve;
using base::resize;
using base::back;
using base::clear;
using base::push_back;

GenericVector<T>& operator+=(const GenericVector& other);

// Double the size of the internal array.
Expand All @@ -61,7 +72,7 @@ class GenericVector : public std::vector<T> {
}

int size() const {
return vector::size();
return base::size();
}

// Return the object from an index.
Expand Down Expand Up @@ -442,7 +453,7 @@ class PointerVector : public GenericVector<T*> {
delete GenericVector<T*>::data()[old_index];
}
}
resize(new_size);
GenericVector<T*>::resize(new_size);
}

// Clear the array, calling the clear callback function if any.
Expand Down Expand Up @@ -650,7 +661,7 @@ const T& GenericVector<T>::get(int index) const {
template <typename T>
T GenericVector<T>::pop_back() {
auto b = back();
vector::pop_back();
base::pop_back();
return b;
}

Expand All @@ -666,7 +677,7 @@ void GenericVector<T>::set(const T& t, int index) {
// at the specified index.
template <typename T>
void GenericVector<T>::insert(const T& t, int index) {
vector::insert(begin() + index, t);
base::insert(begin() + index, t);
}

// Removes an element at the given index and
Expand Down
4 changes: 3 additions & 1 deletion src/api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ const int kMaxIntSize = 22;
static void addAvailableLanguages(const STRING &datadir, const STRING &base,
GenericVector<STRING>* langs)
{
const STRING base2 = (base.c_str()[0] == '\0') ? base : base + "/";
auto base2 = base;
if (!base2.empty())
base2 += "/";
const size_t extlen = sizeof(kTrainedDataSuffix);
#ifdef _WIN32
WIN32_FIND_DATA data;
Expand Down
19 changes: 15 additions & 4 deletions src/ccutil/kdpair.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ namespace tesseract {
// A useful base struct to facilitate the common operation of sorting a vector
// of simple or smart-pointer data using a separate key. Similar to STL pair.
template <typename Key, typename Data>
struct KDPair : public std::pair<Key, Data> {
class KDPair : public std::pair<Key, Data> {
using base = std::pair<Key, Data>;
public:
using std::pair<Key, Data>::pair;

using base::first;
using base::second;

int operator==(const KDPair<Key, Data>& other) const {
return first == other.first;
}
Expand All @@ -58,7 +63,8 @@ struct KDPair : public std::pair<Key, Data> {
// Specialization of KDPair to provide operator< for sorting in increasing order
// and recasting of data pointers for use with DoublePtr.
template <typename Key, typename Data>
struct KDPairInc : public KDPair<Key, Data> {
class KDPairInc : public KDPair<Key, Data> {
public:
using KDPair<Key, Data>::KDPair;

// Operator< facilitates sorting in increasing order.
Expand All @@ -70,7 +76,8 @@ struct KDPairInc : public KDPair<Key, Data> {
// Specialization of KDPair to provide operator< for sorting in decreasing order
// and recasting of data pointers for use with DoublePtr.
template <typename Key, typename Data>
struct KDPairDec : public KDPair<Key, Data> {
class KDPairDec : public KDPair<Key, Data> {
public:
using KDPair<Key, Data>::KDPair;

// Operator< facilitates sorting in decreasing order by using operator> on
Expand All @@ -87,14 +94,18 @@ struct KDPairDec : public KDPair<Key, Data> {
// only a single instance of KDPtrPair holds a specific data pointer.
template <typename Key, typename Data>
class KDPtrPair : public std::pair<Key, std::unique_ptr<Data>> {
using base = std::pair<Key, std::unique_ptr<Data>>;
public:
using base::first;
using base::second;

KDPtrPair() = default;
KDPtrPair(Key k, Data* d) : std::pair<Key, std::unique_ptr<Data>>(k, d) {}
KDPtrPair(KDPtrPair &&src) = default;
KDPtrPair &operator=(KDPtrPair &&src) = default;

int operator==(const KDPtrPair<Key, Data>& other) const {
return key_ == other.key_;
return key() == other.key();
}

// Accessors.
Expand Down

3 comments on commit 6b22972

@Micke3rd
Copy link

@Micke3rd Micke3rd commented on 6b22972 Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from this commit vcpkg cmake win64 build doesnt work anymore. til actual bb6dbd2

@zdenop
Copy link
Contributor

@zdenop zdenop commented on 6b22972 Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not maintain vcpkg. Anyway without please error message and description how to reproduce problem we can not help you.

@Micke3rd
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was a typo in my build script ... thank you for the quick reply ! I can confirm your code works :-)

Please sign in to comment.