Skip to content

Commit

Permalink
Fixed some compile errors as it relates to dependent types in C++. Fo…
Browse files Browse the repository at this point in the history
…r some reason C++Builder has a hard time with dependent types (i.e using the typename keyword). When I typedef these definitions, the compiler has a much more pleasant time.
  • Loading branch information
saadware committed Oct 10, 2011
1 parent d7b8e81 commit 8a7baf3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/google/protobuf/descriptor_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(

// Try to look up the symbol to make sure a super-symbol doesn't already
// exist.
typename std::map<std::string, Value>::iterator iter = FindLastLessOrEqual(name);
StringValueMapType::iterator iter = FindLastLessOrEqual(name);

if (iter == by_symbol_.end()) {
// Apparently the map is currently empty. Just insert and be done with it.
by_symbol_.insert(typename std::map<std::string, Value>::value_type(name, value));
by_symbol_.insert(StringValueMapType::value_type(name, value));
return true;
}

Expand All @@ -128,7 +128,7 @@ bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(

// Insert the new symbol using the iterator as a hint, the new entry will
// appear immediately before the one the iterator is pointing at.
by_symbol_.insert(iter, typename std::map<std::string, Value>::value_type(name, value));
by_symbol_.insert(iter, StringValueMapType::value_type(name, value));

return true;
}
Expand Down Expand Up @@ -179,7 +179,7 @@ Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile(
template <typename Value>
Value SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol(
const std::string& name) {
typename std::map<std::string, Value>::iterator iter = FindLastLessOrEqual(name);
StringValueMapType::iterator iter = FindLastLessOrEqual(name);

return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ?
iter->second : Value();
Expand Down Expand Up @@ -218,7 +218,7 @@ SimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual(
// Find the last key in the map which sorts less than or equal to the
// symbol name. Since upper_bound() returns the *first* key that sorts
// *greater* than the input, we want the element immediately before that.
typename std::map<std::string, Value>::iterator iter = by_symbol_.upper_bound(name);
StringValueMapType::iterator iter = by_symbol_.upper_bound(name);
if (iter != by_symbol_.begin()) --iter;
return iter;
}
Expand Down
8 changes: 5 additions & 3 deletions src/google/protobuf/descriptor_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {
std::vector<int>* output);

private:
std::map<std::string, Value> by_name_;
std::map<std::string, Value> by_symbol_;
typedef std::map<std::string, Value> StringValueMap;
typedef typename StringValueMap StringValueMapType;
StringValueMap by_name_;
StringValueMap by_symbol_;
std::map<std::pair<std::string, int>, Value> by_extension_;

// Invariant: The by_symbol_ map does not contain any symbols which are
Expand Down Expand Up @@ -233,7 +235,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {

// Find the last entry in the by_symbol_ map whose key is less than or
// equal to the given name.
typename std::map<std::string, Value>::iterator FindLastLessOrEqual(
StringValueMapType::iterator FindLastLessOrEqual(
const std::string& name);

// True if either the arguments are equal or super_symbol identifies a
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/repeated_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ inline void RepeatedField<Element>::Truncate(int new_size) {
}

template <typename Element>
inline void RepeatedField<Element>::MoveArray(
void RepeatedField<Element>::MoveArray(
Element to[], Element from[], int array_size) {
memcpy(to, from, array_size * sizeof(Element));
}
Expand Down
3 changes: 0 additions & 3 deletions src/google/protobuf/stubs/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ inline BOOL GetMessage(
}
#endif


#ifndef __CPPBUILDER
namespace std {}
#endif

namespace google {
namespace protobuf {
Expand Down
5 changes: 3 additions & 2 deletions src/google/protobuf/stubs/map-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ bool InsertOrUpdate(Collection * const collection,
template <typename Collection, typename Key, typename Value>
bool InsertIfNotPresent(Collection * const collection,
const Key& key, const Value& value) {
std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type(key, value));
typedef typename Collection CollectionTypeName;
std::pair<CollectionTypeName::iterator, bool> ret =
collection->insert(CollectionTypeName::value_type(key, value));
return ret.second;
}

Expand Down

0 comments on commit 8a7baf3

Please sign in to comment.