Compiler error with std::map and dense_hash_map in GTEST - c++

I am getting this error when I try to use my project/module in my GOOGLE TESTS.
gcc.compile.c++ bin/gcc-4.8.3/debug/link-static/gmock_test.o
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:130:11: error: redefinition of ‘class std::tuple< <template-parameter-1-1> >’
class tuple : public _Tuple_impl<0, _Elements...>
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:388:11: error: previous definition of ‘class std::tuple< <template-parameter-1-1> >’
class tuple : public _Tuple_impl<0, _Elements...>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:164:20: error: redefinition of ‘class std::tuple<>’
template<> class tuple<> { };
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:512:11: error: previous definition of ‘class std::tuple<>’
class tuple<>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:168:11: error: redefinition of ‘class std::tuple<_T1, _T2>’
class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:521:11: error: previous definition of ‘class std::tuple<_T1, _T2>’
class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
^
In file included from /usr/include/c++/4.8.2/tuple:38:0,
from /usr/include/c++/4.8.2/bits/stl_map.h:63,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/utility:83:24: error: template parameter ‘long unsigned int _Int’
template<std::size_t _Int, class _Tp>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:223:12: error: redeclared here as ‘int __i’
struct tuple_element;
^
/usr/include/c++/4.8.2/tr1/tuple:230:12: error: specialization of ‘template<long unsigned int _Int, class _Tp> struct std::tuple_element’ in different namespace [-fpermissive]
struct tuple_element<__i, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/4.8.2/tuple:38:0,
from /usr/include/c++/4.8.2/bits/stl_map.h:63,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/utility:84:11: error: from definition of ‘template<long unsigned int _Int, class _Tp> struct std::tuple_element’ [-fpermissive]
class tuple_element;
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:237:12: error: redefinition of ‘struct std::tuple_element<0ul, std::tuple<_El0, _El ...> >’
struct tuple_element<0, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:687:12: error: previous definition of ‘struct std::tuple_element<0ul, std::tuple<_El0, _El ...> >’
struct tuple_element<0, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:248:12: error: redefinition of ‘struct std::tuple_size<std::tuple<_Args1 ...> >’
struct tuple_size<tuple<_Elements...> >
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:737:12: error: previous definition of ‘struct std::tuple_size<std::tuple<_Args1 ...> >’
struct tuple_size<tuple<_Elements...>>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:254:49: error: definition of ‘std::tuple_size<std::tuple<_Args1 ...> >::value’ is not in namespace enclosing ‘std::tuple_size<std::tuple<_Args1 ...> >’ [-fpermissive]
const int tuple_size<tuple<_Elements...> >::value;
Is it related to map and dense_hash_map usage together ? Please help?

Since it solved your problem I'm making this an answer: set -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=0 to instruct the compilation not to use tr1 tuple nor its own tuple implementation.

Related

How to fix malfunctioning G++ Complier?

The G++ complier is not working. Yesterday I was updating MinGW and Windows PATHS to get Natbeans working but now Visual Studio Code is not Saying "Hello World", It is giving 20+ errors each run.
Any ideas on how to fix so I can run my program? I Uninstalled and Reinstalled MinGw twice but it did not work
Some of the Errors:
required from 'class std::__cxx11::basic_string<char16_t>'
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5677:41:
required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:61:53:
error: no type named 'size_type' in 'struct
std::allocator_traitsstd::allocator<char16_t >'
typedef typename _Base_type::size_type size_type;
^~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:62:53:
error: no type named 'difference_type' in 'struct
std::allocator_traitsstd::allocator<char16_t >'
typedef typename _Base_type::difference_type difference_type;
^~~~~~~~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:70:23:
error: no members matching
'__gnu_cxx::__alloc_traitsstd::allocator<char16_t >::_Base_type {aka
std::allocator_traitsstd::allocator<char16_t >}::max_size' in
'__gnu_cxx::__alloc_traitsstd::allocator<char16_t >::_Base_type {aka
struct std::allocator_traitsstd::allocator<char16_t >}'
using _Base_type::max_size;
^~~~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h: In
member function 'size_t std::hashstd::__cxx11::basic_string<char16_t
::operator()(const u16string&) const': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5678:42:
error: 'const u16string {aka const class
std::__cxx11::basic_string<char16_t>}' has no member named 'length'
__s.length() * sizeof(char16_t)); }
^~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:40:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h: In
instantiation of 'struct
__gnu_cxx::__alloc_traitsstd::allocator<char32_t >': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:75:24:
required from 'class std::__cxx11::basic_string<char32_t>'
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5692:41:
required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:61:53:
error: no type named 'size_type' in 'struct
std::allocator_traitsstd::allocator<char32_t >'
typedef typename _Base_type::size_type size_type;
^~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:62:53:
error: no type named 'difference_type' in 'struct
std::allocator_traitsstd::allocator<char32_t >'
typedef typename _Base_type::difference_type difference_type;
^~~~~~~~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:70:23:
error: no members matching
'__gnu_cxx::__alloc_traitsstd::allocator<char32_t >::_Base_type {aka
std::allocator_traitsstd::allocator<char32_t >}::max_size' in
'__gnu_cxx::__alloc_traitsstd::allocator<char32_t >::_Base_type {aka
struct std::allocator_traitsstd::allocator<char32_t >}'
using _Base_type::max_size;
^~~~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h: In
member function 'size_t std::hashstd::__cxx11::basic_string<char32_t
::operator()(const u32string&) const': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5693:42:
error: 'const u32string {aka const class
std::__cxx11::basic_string<char32_t>}' has no member named 'length'
The Code so far (Want it to print Hello World to the Console using C++):
#include <iostream>
int main()
{
//Prints Hello World to the Console
std::cout << "Hello World" << std::endl;
}
Desired output:
"Hello World"

C++17 forward declarations of custom structures in not working with custom Hash maps

This is little frustrating me at this point, but I am not sure what am I doing wrong. My code is not compiling for using a hashmap with a custom hash function, which I think should be just okay to compiler.
#include <iostream>
#include <queue>
#include <unordered_map>
struct Key;
struct THash;
struct TEqual;
class Cache {
private:
uint64_t capacity;
uint64_t time_ticker;
std::unordered_map<Key, int32_t, THash, TEqual> map_keys;
std::priority_queue<Key> lru_min_heap;
void RehashPriorityQueue()
{
lru_min_heap = std::priority_queue<Key>();
for (auto &&iter : map_keys) lru_min_heap.emplace(iter.first);
}
public:
Cache(const uint64_t cache_size=1) : capacity(cache_size), time_ticker(0) {}
~Cache(){}
void Set(int32_t key, int32_t value) {
time_ticker++;
auto _key = Key(key, time_ticker);
auto find_key = map_keys.find(_key);
if(capacity) capacity--;
else
{
auto lru = lru_min_heap.top(); lru_min_heap.pop();
auto find_key_lru = map_keys.find(lru);
if(find_key_lru != map_keys.end()) map_keys.erase(find_key_lru);
}
if(find_key != map_keys.end())
{
map_keys.erase(find_key);
RehashPriorityQueue();
}
map_keys.emplace(_key, value);
lru_min_heap.emplace(_key);
}
int32_t Get(int32_t key) {
time_ticker++;
int ret = 0;
auto _key = Key(key, time_ticker);
auto find_key = map_keys.find(_key);
if(find_key != map_keys.end()) {
ret = find_key->second;
map_keys.erase(find_key);
RehashPriorityQueue();
map_keys.emplace(_key, ret);
lru_min_heap.emplace(_key);
}
else
{
std::cout<<"None ";
}
return ret;
}
};
struct Key {
int32_t id;
uint64_t weightage;
Key(int32_t id, uint64_t weightage=1) : id(id), weightage(weightage) {};
bool operator<(const Key &other) const { return weightage > other.weightage;}
size_t operator()(const Key& tr) const {
return std::hash<int32_t>()(tr.id);
}
};
struct THash {
size_t operator()(const Key& tr) const {
return std::hash<int32_t>()(tr.id);
}
};
struct TEqual {
bool operator()(const Key& tr1, const Key& tr2) const {
if (tr1.id == tr2.id) return true;
return false;
}
};
int main()
{
Cache cache(2);
cache.Set(3, 3);
std::cout<<cache.Get(3)<<"\n";
return 0;
}
compiler error:
In file included from /usr/include/c++/4.9/bits/hashtable.h:35:0,
from /usr/include/c++/4.9/unordered_map:47,
from 3:
/usr/include/c++/4.9/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::__is_noexcept_hash<Key, THash>':
/usr/include/c++/4.9/type_traits:134:12: required from 'struct std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> >'
/usr/include/c++/4.9/type_traits:145:38: required from 'struct std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
/usr/include/c++/4.9/bits/unordered_map.h:100:66: required from 'class std::unordered_map<Key, int, THash, TEqual>'
13:53: required from here
/usr/include/c++/4.9/bits/hashtable_policy.h:85:33: error: no match for call to '(const THash) (const Key&)'
noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
^
In file included from /usr/include/c++/4.9/bits/move.h:57:0,
from /usr/include/c++/4.9/bits/stl_pair.h:59,
from /usr/include/c++/4.9/bits/stl_algobase.h:64,
from /usr/include/c++/4.9/bits/char_traits.h:39,
from /usr/include/c++/4.9/ios:40,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/type_traits: In instantiation of 'struct std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >':
/usr/include/c++/4.9/bits/unordered_map.h:100:66: required from 'class std::unordered_map<Key, int, THash, TEqual>'
13:53: required from here
/usr/include/c++/4.9/type_traits:145:38: error: 'value' is not a member of 'std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> >'
: public integral_constant<bool, !_Pp::value>
^
In file included from /usr/include/c++/4.9/unordered_map:48:0,
from 3:
/usr/include/c++/4.9/bits/unordered_map.h: In instantiation of 'class std::unordered_map<Key, int, THash, TEqual>':
13:53: required from here
/usr/include/c++/4.9/bits/unordered_map.h:100:66: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
^
/usr/include/c++/4.9/bits/unordered_map.h:107:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::key_type key_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:108:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::value_type value_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:109:48: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::mapped_type mapped_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:110:43: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::hasher hasher;
^
/usr/include/c++/4.9/bits/unordered_map.h:111:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::key_equal key_equal;
^
/usr/include/c++/4.9/bits/unordered_map.h:112:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::allocator_type allocator_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:117:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::pointer pointer;
^
/usr/include/c++/4.9/bits/unordered_map.h:118:50: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_pointer const_pointer;
^
/usr/include/c++/4.9/bits/unordered_map.h:119:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::reference reference;
^
/usr/include/c++/4.9/bits/unordered_map.h:120:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_reference const_reference;
^
/usr/include/c++/4.9/bits/unordered_map.h:121:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::iterator iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:122:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_iterator const_iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:123:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::local_iterator local_iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:124:57: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_local_iterator const_local_iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:125:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::size_type size_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:126:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::difference_type difference_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:242:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
operator=(initializer_list<value_type> __l)
^
/usr/include/c++/4.9/bits/unordered_map.h:340:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
emplace(_Args&&... __args)
^
/usr/include/c++/4.9/bits/unordered_map.h:392:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
insert(const value_type& __x)
^
/usr/include/c++/4.9/bits/unordered_map.h:399:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
insert(_Pair&& __x)
^
/usr/include/c++/4.9/bits/unordered_map.h:459:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
insert(initializer_list<value_type> __l)
^
/usr/include/c++/4.9/bits/unordered_map.h:604:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
equal_range(const key_type& __x)
^
/usr/include/c++/4.9/bits/unordered_map.h:608:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
equal_range(const key_type& __x) const
^
In file included from /usr/include/c++/4.9/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.9/bits/char_traits.h:39,
from /usr/include/c++/4.9/ios:40,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/stl_pair.h: In instantiation of 'struct std::pair<const Key, int>':
19:28: required from here
/usr/include/c++/4.9/bits/stl_pair.h:101:11: error: 'std::pair<_T1, _T2>::first' has incomplete type
_T1 first; /// #c first is a copy of the first object
^
5:8: error: forward declaration of 'const struct Key'
In member function 'void Cache::RehashPriorityQueue()':
19:28: error: no matching function for call to 'begin(std::unordered_map<Key, int, THash, TEqual>&)'
19:28: note: candidates are:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
begin(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.9/initializer_list:89:5: note: template argument deduction/substitution failed:
19:28: note: 'std::unordered_map<Key, int, THash, TEqual>' is not derived from 'std::initializer_list<_Tp>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:87:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
begin(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.9/bits/range_access.h:87:5: note: template argument deduction/substitution failed:
19:28: note: mismatched types '_Tp [_Nm]' and 'std::unordered_map<Key, int, THash, TEqual>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)
begin(const _Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.9/bits/range_access.h:58:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:58:5: error: 'const class std::unordered_map<Key, int, THash, TEqual>' has no member named 'begin'
/usr/include/c++/4.9/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.9/bits/range_access.h:48:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:48:5: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'begin'
19:28: error: no matching function for call to 'end(std::unordered_map<Key, int, THash, TEqual>&)'
19:28: note: candidates are:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.9/initializer_list:99:5: note: template argument deduction/substitution failed:
19:28: note: 'std::unordered_map<Key, int, THash, TEqual>' is not derived from 'std::initializer_list<_Tp>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:97:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
end(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.9/bits/range_access.h:97:5: note: template argument deduction/substitution failed:
19:28: note: mismatched types '_Tp [_Nm]' and 'std::unordered_map<Key, int, THash, TEqual>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
end(const _Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.9/bits/range_access.h:78:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:78:5: error: 'const class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
/usr/include/c++/4.9/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&)
end(_Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.9/bits/range_access.h:68:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:68:5: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
In constructor 'Cache::Cache(uint64_t)':
23:77: error: no matching function for call to 'std::unordered_map<Key, int, THash, TEqual>::unordered_map()'
23:77: note: candidates are:
In file included from /usr/include/c++/4.9/unordered_map:48:0,
from 3:
/usr/include/c++/4.9/bits/unordered_map.h:172:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&&) [with _Key = Key; _Tp = int; _Hash = THash; _Pred = TEqual; _Alloc = std::allocator<std::pair<const Key, int> >]
unordered_map(unordered_map&&) = default;
^
/usr/include/c++/4.9/bits/unordered_map.h:172:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/4.9/bits/unordered_map.h:169:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&) [with _Key = Key; _Tp = int; _Hash = THash; _Pred = TEqual; _Alloc = std::allocator<std::pair<const Key, int> >]
unordered_map(const unordered_map&) = default;
^
/usr/include/c++/4.9/bits/unordered_map.h:169:7: note: candidate expects 1 argument, 0 provided
In member function 'void Cache::Set(int32_t, int32_t)':
28:41: error: invalid use of incomplete type 'struct Key'
5:8: error: forward declaration of 'struct Key'
29:34: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'find'
34:41: error: 'Key lru' has incomplete type
35:42: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'find'
36:41: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
36:57: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'erase'
39:33: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
41:22: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'erase'
45:18: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'emplace'
In member function 'int32_t Cache::Get(int32_t)':
52:41: error: invalid use of incomplete type 'struct Key'
5:8: error: forward declaration of 'struct Key'
53:34: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'find'
54:33: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
56:22: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'erase'
58:22: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'emplace'

Eigen ref with child matrix class

I've got the following code:
#include <iostream>
#include <eigen3/Eigen/Dense>
class MyVectorType: public Eigen::Matrix<double, 3, 1> {
public:
MyVectorType(void) :
Eigen::Matrix<double, 3, 1>() {
}
typedef Eigen::Matrix<double, 3, 1> Base;
// This constructor allows you to construct MyVectorType from Eigen expressions
template<typename OtherDerived>
MyVectorType(const Eigen::MatrixBase<OtherDerived>& other) :
Eigen::Matrix<double, 3, 1>(other) {
}
// This method allows you to assign Eigen expressions to MyVectorType
template<typename OtherDerived>
MyVectorType & operator=(const Eigen::MatrixBase<OtherDerived>& other) {
this->Base::operator=(other);
return *this;
}
//other custom methods here
};
void init(Eigen::Ref<MyVectorType>& m) {
for (int i = 0; i < 3; i++)
for (int j = 0; j < 1; j++)
m(i, j) = 1;
}
int main() {
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign, 12,
12> mm(3, 1);
Eigen::Ref<MyVectorType> rr(mm);
init(rr);
std::cout << mm << std::endl;
return 0;
}
I defined my own class but when I try to the Ref class I have the following error from gcc:
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++98 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
In file included from /usr/include/eigen3/Eigen/Core:449:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Map.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:18:8: required from ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:32:54: required from ‘struct Eigen::internal::accessors_level<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:113:75: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Map.h:18:8: error: invalid use of incomplete type ‘struct Eigen::internal::traits<MyVectorType>’
struct traits<Map<PlainObjectType, MapOptions, StrideType> >
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:346:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: note: declaration of ‘struct Eigen::internal::traits<MyVectorType>’
template<typename T> struct traits;
^~~~~~
In file included from /usr/include/eigen3/Eigen/Core:449:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Map.h:30:32: error: incomplete type ‘Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >::TraitsBase {aka Eigen::internal::traits<MyVectorType>}’ used in nested name specifier
Flags0 = TraitsBase::Flags & (~NestByRefBit),
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:348:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h: In instantiation of ‘struct Eigen::internal::is_lvalue<MyVectorType>’:
/usr/include/eigen3/Eigen/src/Core/Map.h:31:47: required from ‘struct Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:18:8: required from ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:32:54: required from ‘struct Eigen::internal::accessors_level<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:113:75: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:642:53: error: incomplete type ‘Eigen::internal::traits<MyVectorType>’ used in nested name specifier
bool(traits<ExpressionType>::Flags & LvalueBit) };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h: In instantiation of ‘class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:58:34: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: error: no type named ‘XprKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:42:62: error: no type named ‘XprKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::dense_xpr_base<Derived>::type Base;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:43:10: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
enum {
^
/usr/include/eigen3/Eigen/src/Core/MapBase.h:43:10: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/MapBase.h:49:61: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::traits<Derived>::StorageKind StorageKind;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:50:56: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::traits<Derived>::Scalar Scalar;
^~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:51:60: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
^~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:52:46: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename NumTraits<Scalar>::Real RealScalar;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:57:22: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
PointerType;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:59:17: error: using-declaration for non-member at class scope
using Base::derived;
^~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:63:17: error: using-declaration for non-member at class scope
using Base::MaxRowsAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:64:17: error: using-declaration for non-member at class scope
using Base::MaxColsAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:65:17: error: using-declaration for non-member at class scope
using Base::MaxSizeAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:66:17: error: using-declaration for non-member at class scope
using Base::IsVectorAtCompileTime;
^~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:67:17: error: using-declaration for non-member at class scope
using Base::Flags;
^~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:68:17: error: using-declaration for non-member at class scope
using Base::IsRowMajor;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:70:17: error: using-declaration for non-member at class scope
using Base::rows;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:71:17: error: using-declaration for non-member at class scope
using Base::cols;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:72:17: error: using-declaration for non-member at class scope
using Base::size;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:73:17: error: using-declaration for non-member at class scope
using Base::coeff;
^~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:74:17: error: using-declaration for non-member at class scope
using Base::coeffRef;
^~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:75:17: error: using-declaration for non-member at class scope
using Base::lazyAssign;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:76:17: error: using-declaration for non-member at class scope
using Base::eval;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:78:17: error: using-declaration for non-member at class scope
using Base::innerStride;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:79:17: error: using-declaration for non-member at class scope
using Base::outerStride;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:80:17: error: using-declaration for non-member at class scope
using Base::rowStride;
^~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:81:17: error: using-declaration for non-member at class scope
using Base::colStride;
^~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:84:25: error: using-declaration for non-member at class scope
using Base::operator=;
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘StorageIndex’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘MaxSizeAtCompileTime’ is not a member of ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘IsVectorAtCompileTime’ is not a member of ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no members matching ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}::derived’ in ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no members matching ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}::const_cast_derived’ in ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘class Eigen::Ref<MyVectorType>’:
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘StorageIndex’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no members matching ‘Eigen::Ref<MyVectorType>::Base {aka Eigen::RefBase<Eigen::Ref<MyVectorType> >}::derived’ in ‘Eigen::Ref<MyVectorType>::Base {aka class Eigen::RefBase<Eigen::Ref<MyVectorType> >}’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no members matching ‘Eigen::Ref<MyVectorType>::Base {aka Eigen::RefBase<Eigen::Ref<MyVectorType> >}::const_cast_derived’ in ‘Eigen::Ref<MyVectorType>::Base {aka class Eigen::RefBase<Eigen::Ref<MyVectorType> >}’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
../main.cpp: In function ‘void init(Eigen::Ref<MyVectorType>&)’:
../main.cpp:26:10: error: no match for call to ‘(Eigen::Ref<MyVectorType>) (int&, int&)’
m(i, j) = 1;
^
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >::match<Eigen::Matrix<double, -1, -1, 0, 12, 12> >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:197:63: required by substitution of ‘template<class Derived> Eigen::Ref<MyVectorType>::Ref(const Eigen::PlainObjectBase<Derived>&, typename Eigen::internal::enable_if<(bool)(Eigen::internal::traits<Eigen::Ref<MyVectorType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:44:25: error: incomplete type ‘Eigen::internal::traits<MyVectorType>’ used in nested name specifier
AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(Unaligned)) || (DerivedAlignment >= int(Alignment)), // FIXME the first condition is not very clear, it should be replaced by the required alignment
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:347:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h: In instantiation of ‘static void Eigen::PlainObjectBase<Derived>::_check_template_params() [with Derived = Eigen::Matrix<double, 3, 1, 0, 12, 12>]’:
/usr/include/eigen3/Eigen/src/Core/Matrix.h:261:35: required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix() [with _Scalar = double; int _Rows = 3; int _Cols = 1; int _Options = 0; int _MaxRows = 12; int _MaxCols = 12]’
../main.cpp:7:58: required from here
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:899:7: error: ‘INVALID_MATRIX_TEMPLATE_PARAMETERS’ is not a member of ‘Eigen::internal::static_assertion<false>’
EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&RowMajor)==RowMajor)
^
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘Eigen::RefBase<Derived>::RefBase() [with Derived = Eigen::Ref<MyVectorType>]’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:208:5: required from ‘Eigen::Ref<PlainObjectType, Options, StrideType>::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>; PlainObjectType = MyVectorType; int Options = 0; StrideType = Eigen::OuterStride<>; typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:86:100: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(int, int, int)’
StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime)
^
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘void Eigen::RefBase<Derived>::construct(Expression&) [with Expression = Eigen::Matrix<double, -1, -1, 0, 12, 12>; Derived = Eigen::Ref<MyVectorType>]’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:210:22: required from ‘Eigen::Ref<PlainObjectType, Options, StrideType>::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>; PlainObjectType = MyVectorType; int Options = 0; StrideType = Eigen::OuterStride<>; typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:101:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, int, Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Index)’
::new (static_cast<Base*>(this)) Base(expr.data(), 1, expr.size());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:106:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Index, int)’
::new (static_cast<Base*>(this)) Base(expr.data(), expr.size(), 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:109:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, Eigen::Index, Eigen::Index)’
::new (static_cast<Base*>(this)) Base(expr.data(), expr.rows(), expr.cols());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
Is possible to pass by reference a dynamic matrix to a fixed one using a custom child class?
Eigen::Ref is not intended to work with own custom types (that would be possible, but is way to complicated for this purpose). Simply use Eigen::Ref<MyVectorType::Base>. Also if a Ref is intended to be an L-value (i.e., writable), you should pass it by-value, like so
void init(Eigen::Ref<MyVectorType::Base> m) {
// ...
That way you don't need to manually generate a temporary when calling init:
int main() {
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign, 12,
12> mm(3, 1);
// Eigen::Ref<MyVectorType> rr(mm); // not necessary!
init(mm); // implicitly generates a temporary `Ref` object
// ...
For more details, see the online documentation of Ref: https://eigen.tuxfamily.org/dox/classEigen_1_1Ref.html

Including header file in .cpp causes nasty error

I have a header file called transaction_gen.h and a corresponding cpp file called transaction_gen.cpp.
Here is what I have in transaction_gen.h
#ifndef BITCOIN_TEST_GEN_TRANSACTION_GEN_H
#define BITCOIN_TEST_GEN_TRANSACTION_GEN_H
#include <rapidcheck/gen/Arbitrary.h>
#include <rapidcheck/Gen.h>
#include "primitives/transaction.h"
#include "script/script.h"
#include "amount.h"
#include "test/gen/script_gen.h"
#include "test/gen/crypto_gen.h"
namespace rc {
template<>
struct Arbitrary<COutPoint> {
static Gen<COutPoint> arbitrary() {
return gen::map(gen::tuple(gen::arbitrary<uint256>(), gen::arbitrary<uint32_t>()), [](std::tuple<uint256, uint32_t> outPointPrimitives) {
uint32_t nIn;
uint256 nHashIn;
std::tie(nHashIn, nIn) = outPointPrimitives;
return COutPoint(nHashIn, nIn);
});
};
};
template<>
struct Arbitrary<CTxIn> {
static Gen<CTxIn> arbitrary() {
return gen::map(gen::tuple(gen::arbitrary<COutPoint>(), gen::arbitrary<CScript>(), gen::arbitrary<uint32_t>()), [](std::tuple<COutPoint, CScript, uint32_t> txInPrimitives) {
COutPoint outpoint;
CScript script;
uint32_t sequence;
std::tie(outpoint,script,sequence) = txInPrimitives;
return CTxIn(outpoint,script,sequence);
});
};
};
/** Generates one or more inputs */
Gen<std::vector<CTxIn>> oneOrMoreInputs();
template<>
struct Arbitrary<CAmount> {
static Gen<CAmount> arbitrary() {
//why doesn't this generator call work? It seems to cause an infinite loop.
//return gen::arbitrary<int64_t>();
return gen::inRange(std::numeric_limits<int64_t>::min(),std::numeric_limits<int64_t>::max());
};
};
template<>
struct Arbitrary<CTxOut> {
static Gen<CTxOut> arbitrary() {
return gen::map(gen::tuple(gen::arbitrary<CAmount>(), gen::arbitrary<CScript>()), [](std::tuple<CAmount, CScript> txOutPrimitives) {
CAmount amount;
CScript script;
std::tie(amount,script) = txOutPrimitives;
return CTxOut(amount,script);
});
};
};
and here is what I have in the corresponding cpp file
#include <rapidcheck/gen/Arbitrary.h>
#include <rapidcheck/Gen.h>
#include "primitives/transaction.h"
#include "script/script.h"
#include "amount.h"
#include "test/gen/transaction_gen.h"
namespace rc {
/** Generates one or more inputs */
Gen<std::vector<CTxIn>> oneOrMoreInputs() {
return gen::suchThat(gen::arbitrary<std::vector<CTxIn>>(), [](std::vector<CTxIn> vin) {
return vin.size() > 0;
});
}
/** Generates one or more outputs */
Gen<std::vector<CTxOut>> oneOrMoreOutputs() {
return gen::suchThat(gen::arbitrary<std::vector<CTxOut>>(), [](std::vector<CTxOut> vout) {
return vout.size() > 0;
});
}
}
and this will compile fine when I build my program.
However, since I want to be using functionality located in transaction_gen.h I obviously want to include it in my program. However, when I include it I get a long nasty error message:
chris#chris-870Z5E-880Z5E-680Z5E:~/.../src/test$ make
make -C .. bitcoin_test
make[1]: Entering directory `/home/chris/dev/bitcoin/src'
CXX test/test_test_bitcoin-transaction_properties.o
CXX test/gen/test_test_bitcoin-transaction_gen.o
In file included from ./test/gen/script_gen.h:6:0,
from ./test/gen/transaction_gen.h:9,
from test/gen/transaction_gen.cpp:8:
./test/gen/crypto_gen.h: In static member function ‘static rc::Gen<CKey> rc::Arbitrary<CKey>::arbitrary()’:
./test/gen/crypto_gen.h:19:8: error: no matching function for call to ‘map(rc::Arbitrary<CKey>::arbitrary()::<lambda(int)>)’
});
^
In file included from /usr/local/include/rapidcheck/Gen.h:74:0,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: candidate: template<class T, class Mapper> rc::Gen<typename std::decay<typename std::result_of<Mapper(T)>::type>::type> rc::gen::map(rc::Gen<T>, Mapper&&)
Gen<Decay<typename std::result_of<Mapper(T)>::type>> map(Gen<T> gen,
^
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: template argument deduction/substitution failed:
In file included from ./test/gen/script_gen.h:6:0,
from ./test/gen/transaction_gen.h:9,
from test/gen/transaction_gen.cpp:8:
./test/gen/crypto_gen.h:19:8: note: candidate expects 2 arguments, 1 provided
});
^
./test/gen/crypto_gen.h: In static member function ‘static rc::Gen<std::vector<unsigned char, secure_allocator<unsigned char> > > rc::Arbitrary<std::vector<unsigned char, secure_allocator<unsigned char> > >::arbitrary()’:
./test/gen/crypto_gen.h:29:8: error: no matching function for call to ‘map(rc::Arbitrary<std::vector<unsigned char, secure_allocator<unsigned char> > >::arbitrary()::<lambda(CKey)>)’
});
^
In file included from /usr/local/include/rapidcheck/Gen.h:74:0,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: candidate: template<class T, class Mapper> rc::Gen<typename std::decay<typename std::result_of<Mapper(T)>::type>::type> rc::gen::map(rc::Gen<T>, Mapper&&)
Gen<Decay<typename std::result_of<Mapper(T)>::type>> map(Gen<T> gen,
^
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: template argument deduction/substitution failed:
In file included from ./test/gen/script_gen.h:6:0,
from ./test/gen/transaction_gen.h:9,
from test/gen/transaction_gen.cpp:8:
./test/gen/crypto_gen.h:29:8: note: candidate expects 2 arguments, 1 provided
});
^
./test/gen/crypto_gen.h: In static member function ‘static rc::Gen<CPubKey> rc::Arbitrary<CPubKey>::arbitrary()’:
./test/gen/crypto_gen.h:39:8: error: no matching function for call to ‘map(rc::Arbitrary<CPubKey>::arbitrary()::<lambda(CKey)>)’
});
^
In file included from /usr/local/include/rapidcheck/Gen.h:74:0,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: candidate: template<class T, class Mapper> rc::Gen<typename std::decay<typename std::result_of<Mapper(T)>::type>::type> rc::gen::map(rc::Gen<T>, Mapper&&)
Gen<Decay<typename std::result_of<Mapper(T)>::type>> map(Gen<T> gen,
^
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: template argument deduction/substitution failed:
In file included from ./test/gen/script_gen.h:6:0,
from ./test/gen/transaction_gen.h:9,
from test/gen/transaction_gen.cpp:8:
./test/gen/crypto_gen.h:39:8: note: candidate expects 2 arguments, 1 provided
});
^
./test/gen/crypto_gen.h: In static member function ‘static rc::Gen<uint256> rc::Arbitrary<uint256>::arbitrary()’:
./test/gen/crypto_gen.h:49:8: error: no matching function for call to ‘map(rc::Arbitrary<uint256>::arbitrary()::<lambda(int)>)’
});
^
In file included from /usr/local/include/rapidcheck/Gen.h:74:0,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: candidate: template<class T, class Mapper> rc::Gen<typename std::decay<typename std::result_of<Mapper(T)>::type>::type> rc::gen::map(rc::Gen<T>, Mapper&&)
Gen<Decay<typename std::result_of<Mapper(T)>::type>> map(Gen<T> gen,
^
/usr/local/include/rapidcheck/Gen.hpp:15:54: note: template argument deduction/substitution failed:
In file included from ./test/gen/script_gen.h:6:0,
from ./test/gen/transaction_gen.h:9,
from test/gen/transaction_gen.cpp:8:
./test/gen/crypto_gen.h:49:8: note: candidate expects 2 arguments, 1 provided
});
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp: In instantiation of ‘struct rc::Arbitrary<std::vector<unsigned char> >’:
/usr/local/include/rapidcheck/gen/Arbitrary.h:17:33: required by substitution of ‘template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary() [with T = std::vector<unsigned char>]’
./test/gen/script_gen.h:13:66: required from here
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:22:62: error: incomplete type ‘rc::gen::detail::DefaultArbitrary<std::vector<unsigned char> >’ used in nested name specifier
static decltype(gen::detail::DefaultArbitrary<T>::arbitrary()) arbitrary() {
^
In file included from ./test/gen/transaction_gen.h:9:0,
from test/gen/transaction_gen.cpp:8:
./test/gen/script_gen.h: In static member function ‘static rc::Gen<CScript> rc::Arbitrary<CScript>::arbitrary()’:
./test/gen/script_gen.h:13:66: error: no matching function for call to ‘arbitrary()’
return gen::map(gen::arbitrary<std::vector<unsigned char>>(), [](std::vector<unsigned char> script) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: candidate: template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary()
decltype(Arbitrary<T>::arbitrary()) arbitrary() {
^
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: substitution of deduced template arguments resulted in errors seen above
In file included from test/gen/transaction_gen.cpp:8:0:
./test/gen/transaction_gen.h: In static member function ‘static rc::Gen<COutPoint> rc::Arbitrary<COutPoint>::arbitrary()’:
./test/gen/transaction_gen.h:17:23: error: ‘tuple’ is not a member of ‘rc::gen’
return gen::map(gen::tuple(gen::arbitrary<uint256>(), gen::arbitrary<uint32_t>()), [](std::tuple<uint256, uint32_t> outPointPrimitives) {
^
./test/gen/transaction_gen.h:17:23: note: suggested alternative:
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/memory:62,
from /usr/local/include/rapidcheck/Seq.h:4,
from /usr/local/include/rapidcheck/Shrinkable.h:3,
from /usr/local/include/rapidcheck/Gen.h:4,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:83:11: note: ‘std::tuple’
class tuple;
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp: In instantiation of ‘struct rc::Arbitrary<unsigned int>’:
/usr/local/include/rapidcheck/gen/Arbitrary.h:17:33: required by substitution of ‘template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary() [with T = unsigned int]’
./test/gen/transaction_gen.h:17:86: required from here
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:22:62: error: incomplete type ‘rc::gen::detail::DefaultArbitrary<unsigned int>’ used in nested name specifier
static decltype(gen::detail::DefaultArbitrary<T>::arbitrary()) arbitrary() {
^
In file included from test/gen/transaction_gen.cpp:8:0:
./test/gen/transaction_gen.h:17:86: error: no matching function for call to ‘arbitrary()’
return gen::map(gen::tuple(gen::arbitrary<uint256>(), gen::arbitrary<uint32_t>()), [](std::tuple<uint256, uint32_t> outPointPrimitives) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: candidate: template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary()
decltype(Arbitrary<T>::arbitrary()) arbitrary() {
^
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: substitution of deduced template arguments resulted in errors seen above
In file included from test/gen/transaction_gen.cpp:8:0:
./test/gen/transaction_gen.h: In static member function ‘static rc::Gen<CTxIn> rc::Arbitrary<CTxIn>::arbitrary()’:
./test/gen/transaction_gen.h:30:23: error: ‘tuple’ is not a member of ‘rc::gen’
return gen::map(gen::tuple(gen::arbitrary<COutPoint>(), gen::arbitrary<CScript>(), gen::arbitrary<uint32_t>()), [](std::tuple<COutPoint, CScript, uint32_t> txInPrimitives) {
^
./test/gen/transaction_gen.h:30:23: note: suggested alternative:
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/memory:62,
from /usr/local/include/rapidcheck/Seq.h:4,
from /usr/local/include/rapidcheck/Shrinkable.h:3,
from /usr/local/include/rapidcheck/Gen.h:4,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:83:11: note: ‘std::tuple’
class tuple;
^
In file included from test/gen/transaction_gen.cpp:8:0:
./test/gen/transaction_gen.h:30:115: error: no matching function for call to ‘arbitrary()’
return gen::map(gen::tuple(gen::arbitrary<COutPoint>(), gen::arbitrary<CScript>(), gen::arbitrary<uint32_t>()), [](std::tuple<COutPoint, CScript, uint32_t> txInPrimitives) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: candidate: template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary()
decltype(Arbitrary<T>::arbitrary()) arbitrary() {
^
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: template argument deduction/substitution failed:
In file included from test/gen/transaction_gen.cpp:1:0:
/usr/local/include/rapidcheck/gen/Arbitrary.h: In substitution of ‘template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary() [with T = unsigned int]’:
./test/gen/transaction_gen.h:30:115: required from here
/usr/local/include/rapidcheck/gen/Arbitrary.h:17:33: error: ‘arbitrary’ is not a member of ‘rc::Arbitrary<unsigned int>’
decltype(Arbitrary<T>::arbitrary()) arbitrary();
^
In file included from test/gen/transaction_gen.cpp:8:0:
./test/gen/transaction_gen.h: In static member function ‘static rc::Gen<long int> rc::Arbitrary<long int>::arbitrary()’:
./test/gen/transaction_gen.h:48:14: error: ‘inRange’ is not a member of ‘rc::gen’
return gen::inRange(std::numeric_limits<int64_t>::min(),std::numeric_limits<int64_t>::max());
^
./test/gen/transaction_gen.h: In static member function ‘static rc::Gen<CTxOut> rc::Arbitrary<CTxOut>::arbitrary()’:
./test/gen/transaction_gen.h:55:23: error: ‘tuple’ is not a member of ‘rc::gen’
return gen::map(gen::tuple(gen::arbitrary<CAmount>(), gen::arbitrary<CScript>()), [](std::tuple<CAmount, CScript> txOutPrimitives) {
^
./test/gen/transaction_gen.h:55:23: note: suggested alternative:
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/memory:62,
from /usr/local/include/rapidcheck/Seq.h:4,
from /usr/local/include/rapidcheck/Shrinkable.h:3,
from /usr/local/include/rapidcheck/Gen.h:4,
from /usr/local/include/rapidcheck/gen/Arbitrary.h:3,
from test/gen/transaction_gen.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:83:11: note: ‘std::tuple’
class tuple;
^
test/gen/transaction_gen.cpp: In function ‘rc::Gen<std::vector<CTxIn> > rc::oneOrMoreInputs()’:
test/gen/transaction_gen.cpp:14:12: error: ‘suchThat’ is not a member of ‘rc::gen’
return gen::suchThat(gen::arbitrary<std::vector<CTxIn>>(), [](std::vector<CTxIn> vin) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp: In instantiation of ‘struct rc::Arbitrary<std::vector<CTxIn> >’:
/usr/local/include/rapidcheck/gen/Arbitrary.h:17:33: required by substitution of ‘template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary() [with T = std::vector<CTxIn>]’
test/gen/transaction_gen.cpp:14:61: required from here
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:22:62: error: incomplete type ‘rc::gen::detail::DefaultArbitrary<std::vector<CTxIn> >’ used in nested name specifier
static decltype(gen::detail::DefaultArbitrary<T>::arbitrary()) arbitrary() {
^
test/gen/transaction_gen.cpp:14:61: error: no matching function for call to ‘arbitrary()’
return gen::suchThat(gen::arbitrary<std::vector<CTxIn>>(), [](std::vector<CTxIn> vin) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: candidate: template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary()
decltype(Arbitrary<T>::arbitrary()) arbitrary() {
^
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: substitution of deduced template arguments resulted in errors seen above
test/gen/transaction_gen.cpp: In function ‘rc::Gen<std::vector<CTxOut> > rc::oneOrMoreOutputs()’:
test/gen/transaction_gen.cpp:21:12: error: ‘suchThat’ is not a member of ‘rc::gen’
return gen::suchThat(gen::arbitrary<std::vector<CTxOut>>(), [](std::vector<CTxOut> vout) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp: In instantiation of ‘struct rc::Arbitrary<std::vector<CTxOut> >’:
/usr/local/include/rapidcheck/gen/Arbitrary.h:17:33: required by substitution of ‘template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary() [with T = std::vector<CTxOut>]’
test/gen/transaction_gen.cpp:21:62: required from here
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:22:62: error: incomplete type ‘rc::gen::detail::DefaultArbitrary<std::vector<CTxOut> >’ used in nested name specifier
static decltype(gen::detail::DefaultArbitrary<T>::arbitrary()) arbitrary() {
^
test/gen/transaction_gen.cpp:21:62: error: no matching function for call to ‘arbitrary()’
return gen::suchThat(gen::arbitrary<std::vector<CTxOut>>(), [](std::vector<CTxOut> vout) {
^
In file included from /usr/local/include/rapidcheck/gen/Arbitrary.h:22:0,
from test/gen/transaction_gen.cpp:1:
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: candidate: template<class T> decltype (rc::Arbitrary<T>::arbitrary()) rc::gen::arbitrary()
decltype(Arbitrary<T>::arbitrary()) arbitrary() {
^
/usr/local/include/rapidcheck/gen/Arbitrary.hpp:13:37: note: substitution of deduced template arguments resulted in errors seen above
make[1]: *** [test/gen/test_test_bitcoin-transaction_gen.o] Error 1
make[1]: Leaving directory `/home/chris/dev/bitcoin/src'
make: *** [all] Error 2
and I'm not really sure why this is happening. It almost seems like when I include transaction_gen.h it erases all other header files I had included, this the problems like
In file included from ./test/gen/script_gen.h:6:0,
from ./test/gen/transaction_gen.h:9,
from test/gen/transaction_gen.cpp:8:
./test/gen/crypto_gen.h: In static member function ‘static rc::Gen<CKey> rc::Arbitrary<CKey>::arbitrary()’:
./test/gen/crypto_gen.h:19:8: error: no matching function for call to ‘map(rc::Arbitrary<CKey>::arbitrary()::<lambda(int)>)’
});
because this obviously is included properly when I exclude transaction_gen.h. Where am I going wrong here? I feel like this is a pretty simple fix but I've spent a couple hours on it now to avail :/
EDIT: I've pushed this up to github
Here is transaction_gen.h
Here is transaction_gen.cpp
Try remove these lines from transaction_gen.cpp:
#include <rapidcheck/gen/Arbitrary.h>
#include <rapidcheck/Gen.h>
#include "primitives/transaction.h"
#include "script/script.h"
#include "amount.h"
Keep this #include line only:
#include "test/gen/transaction_gen.h"
Your transaction_gen.h is missing a #endif at the end of the file.
Include these in your cpp file also
#include "test/gen/script_gen.h"
#include "test/gen/crypto_gen.h"

Preprocessor Errors Compiling Chrono_io

Recently pulled some code to a new system, and I'm having some trouble compiling chrono_io and ratio_io.
I'm unsure what to change, since the errors appear to affect the preprocessor.
It seems like it must be a cross-platform compatibility issue for which the code doesn't account.
Any ideas how I can resolve these preprocessor and compiler errors?
In file included from Test.cc:12:0:
chrono_io:221:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:789:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:821:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:833:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:845:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:858:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:885:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:36:1: error: ‘_LIBCPP_BEGIN_NAMESPACE_STD’ does not name a type
_LIBCPP_BEGIN_NAMESPACE_STD
^
ratio_io:46:1: error: ‘basic_string’ does not name a type
basic_string<_CharT>
^
ratio_io:58:8: error: ‘ratio_string’ is not a class template
struct ratio_string<atto, char>
^
ratio_io:58:21: error: ‘atto’ was not declared in this scope
struct ratio_string<atto, char>
^
ratio_io:58:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:513:47: note: ‘std::atto’
typedef ratio<1, 1000000000000000000> atto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:59:1: error: explicit specialization of non-template ‘ratio_string’
{
^
ratio_io:60:12: error: ‘string’ does not name a type
static string symbol() {return string(1, 'a');}
^
ratio_io:61:12: error: ‘string’ does not name a type
static string prefix() {return string("atto");}
^
ratio_io:83:8: error: ‘ratio_string’ is not a class template
struct ratio_string<atto, wchar_t>
^
ratio_io:83:21: error: ‘atto’ was not declared in this scope
struct ratio_string<atto, wchar_t>
^
ratio_io:83:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:513:47: note: ‘std::atto’
typedef ratio<1, 1000000000000000000> atto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:83:34: error: ‘ratio_string’ is not a template type
struct ratio_string<atto, wchar_t>
^
ratio_io:92:8: error: ‘ratio_string’ is not a class template
struct ratio_string<femto, char>
^
ratio_io:92:21: error: ‘femto’ was not declared in this scope
struct ratio_string<femto, char>
^
ratio_io:92:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:514:47: note: ‘std::femto’
typedef ratio<1, 1000000000000000> femto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:92:32: error: ‘ratio_string’ is not a template type
struct ratio_string<femto, char>
^
ratio_io:117:8: error: ‘ratio_string’ is not a class template
struct ratio_string<femto, wchar_t>
^
ratio_io:117:21: error: ‘femto’ was not declared in this scope
struct ratio_string<femto, wchar_t>
^
ratio_io:117:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:514:47: note: ‘std::femto’
typedef ratio<1, 1000000000000000> femto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:117:35: error: ‘ratio_string’ is not a template type
struct ratio_string<femto, wchar_t>
^
ratio_io:126:8: error: ‘ratio_string’ is not a class template
struct ratio_string<pico, char>
^
ratio_io:126:21: error: ‘pico’ was not declared in this scope
struct ratio_string<pico, char>
^
ratio_io:126:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:515:47: note: ‘std::pico’
typedef ratio<1, 1000000000000> pico;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:126:31: error: ‘ratio_string’ is not a template type
struct ratio_string<pico, char>
^
ratio_io:151:8: error: ‘ratio_string’ is not a class template
struct ratio_string<pico, wchar_t>
^
ratio_io:151:21: error: ‘pico’ was not declared in this scope
struct ratio_string<pico, wchar_t>
^
ratio_io:151:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:515:47: note: ‘std::pico’
typedef ratio<1, 1000000000000> pico;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:151:34: error: ‘ratio_string’ is not a template type
struct ratio_string<pico, wchar_t>
^
ratio_io:160:8: error: ‘ratio_string’ is not a class template
struct ratio_string<nano, char>
^
ratio_io:160:21: error: ‘nano’ was not declared in this scope
struct ratio_string<nano, char>
^
ratio_io:160:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:516:47: note: ‘std::nano’
typedef ratio<1, 1000000000> nano;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:160:31: error: ‘ratio_string’ is not a template type
struct ratio_string<nano, char>
^
ratio_io:185:8: error: ‘ratio_string’ is not a class template
struct ratio_string<nano, wchar_t>
^
ratio_io:185:21: error: ‘nano’ was not declared in this scope
struct ratio_string<nano, wchar_t>
^
ratio_io:185:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:516:47: note: ‘std::nano’
typedef ratio<1, 1000000000> nano;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:185:34: error: ‘ratio_string’ is not a template type
struct ratio_string<nano, wchar_t>
^
ratio_io:194:8: error: ‘ratio_string’ is not a class template
struct ratio_string<micro, char>
^
ratio_io:194:21: error: ‘micro’ was not declared in this scope
struct ratio_string<micro, char>
^
ratio_io:194:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:517:47: note: ‘std::micro’
typedef ratio<1, 1000000> micro;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:194:32: error: ‘ratio_string’ is not a template type
struct ratio_string<micro, char>
^
ratio_io:219:8: error: ‘ratio_string’ is not a class template
struct ratio_string<micro, wchar_t>
^
ratio_io:219:21: error: ‘micro’ was not declared in this scope
struct ratio_string<micro, wchar_t>
^
ratio_io:219:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:517:47: note: ‘std::micro’
typedef ratio<1, 1000000> micro;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:219:35: error: ‘ratio_string’ is not a template type
struct ratio_string<micro, wchar_t>
^
ratio_io:228:8: error: ‘ratio_string’ is not a class template
struct ratio_string<milli, char>
^
ratio_io:228:21: error: ‘milli’ was not declared in this scope
struct ratio_string<milli, char>
^
ratio_io:228:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:518:47: note: ‘std::milli’
typedef ratio<1, 1000> milli;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:228:32: error: ‘ratio_string’ is not a template type
struct ratio_string<milli, char>
^
ratio_io:253:8: error: ‘ratio_string’ is not a class template
struct ratio_string<milli, wchar_t>
^
ratio_io:253:21: error: ‘milli’ was not declared in this scope
struct ratio_string<milli, wchar_t>
^
ratio_io:253:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:518:47: note: ‘std::milli’
typedef ratio<1, 1000> milli;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:253:35: error: ‘ratio_string’ is not a template type
struct ratio_string<milli, wchar_t>
^
ratio_io:262:8: error: ‘ratio_string’ is not a class template
struct ratio_string<centi, char>
^
ratio_io:262:21: error: ‘centi’ was not declared in this scope
struct ratio_string<centi, char>
^
ratio_io:262:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:519:47: note: ‘std::centi’
typedef ratio<1, 100> centi;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:262:32: error: ‘ratio_string’ is not a template type
struct ratio_string<centi, char>
^
ratio_io:287:8: error: ‘ratio_string’ is not a class template
struct ratio_string<centi, wchar_t>
^
ratio_io:287:21: error: ‘centi’ was not declared in this scope
struct ratio_string<centi, wchar_t>
^
ratio_io:287:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:519:47: note: ‘std::centi’
typedef ratio<1, 100> centi;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:287:35: error: ‘ratio_string’ is not a template type
struct ratio_string<centi, wchar_t>
^
ratio_io:296:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deci, char>
^
ratio_io:296:21: error: ‘deci’ was not declared in this scope
struct ratio_string<deci, char>
^
ratio_io:296:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:520:47: note: ‘std::deci’
typedef ratio<1, 10> deci;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:296:31: error: ‘ratio_string’ is not a template type
struct ratio_string<deci, char>
^
ratio_io:321:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deci, wchar_t>
^
ratio_io:321:21: error: ‘deci’ was not declared in this scope
struct ratio_string<deci, wchar_t>
^
ratio_io:321:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:520:47: note: ‘std::deci’
typedef ratio<1, 10> deci;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:321:34: error: ‘ratio_string’ is not a template type
struct ratio_string<deci, wchar_t>
^
ratio_io:330:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deca, char>
^
ratio_io:330:21: error: ‘deca’ was not declared in this scope
struct ratio_string<deca, char>
^
ratio_io:330:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:521:47: note: ‘std::deca’
typedef ratio< 10, 1> deca;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:330:31: error: ‘ratio_string’ is not a template type
struct ratio_string<deca, char>
^
ratio_io:355:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deca, wchar_t>
^
ratio_io:355:21: error: ‘deca’ was not declared in this scope
struct ratio_string<deca, wchar_t>
^
ratio_io:355:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:521:47: note: ‘std::deca’
typedef ratio< 10, 1> deca;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:355:34: error: ‘ratio_string’ is not a template type
struct ratio_string<deca, wchar_t>
^
ratio_io:364:8: error: ‘ratio_string’ is not a class template
struct ratio_string<hecto, char>
^
ratio_io:364:21: error: ‘hecto’ was not declared in this scope
struct ratio_string<hecto, char>
^
ratio_io:364:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:522:47: note: ‘std::hecto’
typedef ratio< 100, 1> hecto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:364:32: error: ‘ratio_string’ is not a template type
struct ratio_string<hecto, char>
^
ratio_io:389:8: error: ‘ratio_string’ is not a class template
struct ratio_string<hecto, wchar_t>
^
ratio_io:389:21: error: ‘hecto’ was not declared in this scope
struct ratio_string<hecto, wchar_t>
^
ratio_io:389:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:522:47: note: ‘std::hecto’
typedef ratio< 100, 1> hecto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:389:35: error: ‘ratio_string’ is not a template type
struct ratio_string<hecto, wchar_t>
^
ratio_io:398:8: error: ‘ratio_string’ is not a class template
struct ratio_string<kilo, char>
^
ratio_io:398:21: error: ‘kilo’ was not declared in this scope
struct ratio_string<kilo, char>
^
ratio_io:398:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:523:47: note: ‘std::kilo’
typedef ratio< 1000, 1> kilo;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:398:31: error: ‘ratio_string’ is not a template type
struct ratio_string<kilo, char>
^
ratio_io:423:8: error: ‘ratio_string’ is not a class template
struct ratio_string<kilo, wchar_t>
^
ratio_io:423:21: error: ‘kilo’ was not declared in this scope
struct ratio_string<kilo, wchar_t>
^
ratio_io:423:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:523:47: note: ‘std::kilo’
typedef ratio< 1000, 1> kilo;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:423:34: error: ‘ratio_string’ is not a template type
struct ratio_string<kilo, wchar_t>
^
ratio_io:432:8: error: ‘ratio_string’ is not a class template
struct ratio_string<mega, char>
^
ratio_io:432:21: error: ‘mega’ was not declared in this scope
struct ratio_string<mega, char>
^
ratio_io:432:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:524:47: note: ‘std::mega’
typedef ratio< 1000000, 1> mega;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:432:31: error: ‘ratio_string’ is not a template type
struct ratio_string<mega, char>
^
ratio_io:457:8: error: ‘ratio_string’ is not a class template
struct ratio_string<mega, wchar_t>
^
ratio_io:457:21: error: ‘mega’ was not declared in this scope
struct ratio_string<mega, wchar_t>
^
ratio_io:457:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:524:47: note: ‘std::mega’
typedef ratio< 1000000, 1> mega;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:457:34: error: ‘ratio_string’ is not a template type
struct ratio_string<mega, wchar_t>
^
ratio_io:466:8: error: ‘ratio_string’ is not a class template
struct ratio_string<giga, char>
^
ratio_io:466:21: error: ‘giga’ was not declared in this scope
struct ratio_string<giga, char>
^
ratio_io:466:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:525:47: note: ‘std::giga’
typedef ratio< 1000000000, 1> giga;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:466:31: error: ‘ratio_string’ is not a template type
struct ratio_string<giga, char>
^
ratio_io:491:8: error: ‘ratio_string’ is not a class template
struct ratio_string<giga, wchar_t>
^
ratio_io:491:21: error: ‘giga’ was not declared in this scope
struct ratio_string<giga, wchar_t>
^
ratio_io:491:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:525:47: note: ‘std::giga’
typedef ratio< 1000000000, 1> giga;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:491:34: error: ‘ratio_string’ is not a template type
struct ratio_string<giga, wchar_t>
^
ratio_io:500:8: error: ‘ratio_string’ is not a class template
struct ratio_string<tera, char>
^
ratio_io:500:21: error: ‘tera’ was not declared in this scope
struct ratio_string<tera, char>
^
ratio_io:500:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:526:47: note: ‘std::tera’
typedef ratio< 1000000000000, 1> tera;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:500:31: error: ‘ratio_string’ is not a template type
struct ratio_string<tera, char>
^
ratio_io:525:8: error: ‘ratio_string’ is not a class template
struct ratio_string<tera, wchar_t>
^
ratio_io:525:21: error: ‘tera’ was not declared in this scope
struct ratio_string<tera, wchar_t>
^
ratio_io:525:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:526:47: note: ‘std::tera’
typedef ratio< 1000000000000, 1> tera;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:525:34: error: ‘ratio_string’ is not a template type
struct ratio_string<tera, wchar_t>
^
ratio_io:534:8: error: ‘ratio_string’ is not a class template
struct ratio_string<peta, char>
^
ratio_io:534:21: error: ‘peta’ was not declared in this scope
struct ratio_string<peta, char>
^
ratio_io:534:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:527:47: note: ‘std::peta’
typedef ratio< 1000000000000000, 1> peta;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:534:31: error: ‘ratio_string’ is not a template type
struct ratio_string<peta, char>
^
ratio_io:559:8: error: ‘ratio_string’ is not a class template
struct ratio_string<peta, wchar_t>
^
ratio_io:559:21: error: ‘peta’ was not declared in this scope
struct ratio_string<peta, wchar_t>
^
ratio_io:559:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:527:47: note: ‘std::peta’
typedef ratio< 1000000000000000, 1> peta;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:559:34: error: ‘ratio_string’ is not a template type
struct ratio_string<peta, wchar_t>
^
ratio_io:568:8: error: ‘ratio_string’ is not a class template
struct ratio_string<exa, char>
^
ratio_io:568:21: error: ‘exa’ was not declared in this scope
struct ratio_string<exa, char>
^
ratio_io:568:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:528:47: note: ‘std::exa’
typedef ratio< 1000000000000000000, 1> exa;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:568:30: error: ‘ratio_string’ is not a template type
struct ratio_string<exa, char>
^
ratio_io:593:8: error: ‘ratio_string’ is not a class template
struct ratio_string<exa, wchar_t>
^
ratio_io:593:21: error: ‘exa’ was not declared in this scope
struct ratio_string<exa, wchar_t>
^
ratio_io:593:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:528:47: note: ‘std::exa’
typedef ratio< 1000000000000000000, 1> exa;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:593:33: error: ‘ratio_string’ is not a template type
struct ratio_string<exa, wchar_t>
^
ratio_io:599:1: error: ‘_LIBCPP_END_NAMESPACE_STD’ does not name a type
_LIBCPP_END_NAMESPACE_STD
^
In file included from Test.cc:12:0:
chrono_io:1164:1: error: ‘_LIBCPP_END_NAMESPACE_STD’ does not name a type
_LIBCPP_END_NAMESPACE_STD
^
Test.cc: In function ‘void RealDataTest()’:
Test.cc:167:12: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
std::cout << "Time for n->mostRecent: " << (Clock::now() - start) << std::endl;
^
In file included from /usr/include/c++/4.8.2/iostream:39:0,
from Nearby.cc:9,
from Test.cc:5:
/usr/include/c++/4.8.2/ostream:602:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::chrono::duration<long int, std::ratio<1l, 1000000000l> >]’
operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
^
Test.cc:185:12: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
std::cout << "Time for n->deletePost: " << (Clock::now() - start) << std::endl;
^
In file included from /usr/include/c++/4.8.2/iostream:39:0,
from Nearby.cc:9,
from Test.cc:5:
/usr/include/c++/4.8.2/ostream:602:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::chrono::duration<long int, std::ratio<1l, 1000000000l> >]’
operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
^
make: *** [all] Error 1
I haven't played with this code in several years. It is using:
#if __has_feature(cxx_rvalue_references)
__seconds_(std::move(__seconds)),
...
to check if the compiler supports rvalue references (C++11 move semantics). My recommendation is to assume that you have C++11 (since you have to have <chrono> and just remove the __has_feature and the #else branch.
If for some reason you have to support a compiler which doesn't have rvalue references you can:
#define __has_feature(x) 0
and this will select the #else branch everywhere.
__has_feature(cxx_rvalue_references) is a clang extension.
Update
Update to this library.
https://howardhinnant.github.io/date/chrono_io.html
It has been simplified to only streaming durations.