|
|
Home » U++ Library support » U++ Core » stl-compatibility
stl-compatibility [message #39649] |
Fri, 12 April 2013 21:26 |
piotr5
Messages: 107 Registered: November 2005
|
Experienced Member |
|
|
I noticed you have some nice macros for enabling stl-compatibility in upp containers. unfortunately it doesn't always work the way it should. obviously size() you have not added the cv-qualifier const. are there any containers that return GetCount() that could alter the object, or containers that abuse the call for cleaning up?
another more serious problem I noticed when trying the std::includes() template algorithm:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_algobase.h:66:0,
from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/algorithm:62,
from /home/p/upp/uppsrc/Core/Core.h:212,
from /home/p/MyApps/s6/s6.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h: At global scope:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<Upp::Array<Upp::String
>::ConstIterator>’:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_algo.h:3519:2: instantiated from ‘bool std::includes(_IIter1, _IIter1, _IIter2, _IIte
r2) [with _IIter1 = Upp::Array<Upp::String>::ConstIterator, _IIter2 = Upp::Array<Upp::String>::ConstIterator]’
/home/p/MyApps/s6/s6.cpp:10:58: instantiated from ‘bool Upp::IsSubset(const INDEX&, const INDEX&) [with INDEX = Upp::ArrayIndex<Upp::String>]’
/home/p/MyApps/s6/s6.cpp:95:98: instantiated from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h:166:53: error: no type named ‘iterator_category’ in ‘class Upp::A
rray<Upp::String>::ConstIterator’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h:167:53: error: no type named ‘value_type’ in ‘class Upp::Array<Up
p::String>::ConstIterator’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h:168:53: error: no type named ‘difference_type’ in ‘class Upp::Arr
ay<Upp::String>::ConstIterator’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h:169:53: error: no type named ‘pointer’ in ‘class Upp::Array<Upp::
String>::ConstIterator’
/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/stl_iterator_base_types.h:170:53: error: no type named ‘reference’ in ‘class Upp::Array<Upp
::String>::ConstIterator’
is there any list of what algorithms are supported and what aren't? or will this get better with next gcc version?
|
|
|
|
|
Re: stl-compatibility [message #39674 is a reply to message #39649] |
Tue, 16 April 2013 20:11 |
piotr5
Messages: 107 Registered: November 2005
|
Experienced Member |
|
|
I instantiated a class making use of each container's stl-compatibility to check what containers can be used. what I found is:
testIterContainers<Vector<V> >();
testIterContainers<Array<V> >();
/*no conversion from iterator to const_iterator*/ // testIterContainers<Segtor<V> >();
// testIterContainers<Index<V> >();
// testIterContainers<ArrayIndex<V> >();
testIterContainers<VectorMap<int,V> >();
testIterContainers<ArrayMap<int,V> >();
/*no conversion from iterator to const_iterator*/ // testIterContainers<SegtorMap<int,V> >();
// testIterContainers<One<V> >();
// testIterContainers<Buffer<V> >();
// testIterContainers<Mitor<V> >();
// testIterContainers<LinkElement<V> >();
// testIterContainers<LRUCache<V> >();
testIterContainers<InVector<V> >();
/*no operator=(ConstIterator) for InArray*/ // testIterContainers<InArray<V> >();
// testIterContainers<SortedIndex<V> >();
testIterContainers<SortedVectorMap<int,V> >();
/*no operator=(ConstIterator) for InArray*/ // testIterContainers<SortedArrayMap<int,V> >();
/*no conversion from iterator to const_iterator*/ // testIterContainers<BiVector<V> >();
/*no conversion from iterator to const_iterator*/ // testIterContainers<BiArray<V> >();
the containers I used all at least instantiate and return an iterator, the containers I commented out have no stl-compatibility. additional comments are talking of 2 compilation-problems: InArray delegates SetEnd to InVector resulting in
/home/p/upp/uppsrc/Core/InVector.hpp: In member function ‘void Upp::InArray<T>::SetEnd(Upp::InArray<T>::ConstIterator&) const [with T = Upp::Vector<in
t>]’:
/home/p/upp/uppsrc/Core/InVector.h:332:65: instantiated from ‘Upp::InArray<T>::Iterator Upp::InArray<T>::End() [with T = Upp::Vector<int>]’
/home/p/upp/uppsrc/Core/InVector.h:345:2: instantiated from ‘Upp::InArray<T>::iterator Upp::InArray<T>::end() [with T = Upp::Vector<int>, Upp::InArr
ay<T>::iterator = Upp::InArray<Upp::Vector<int> >::Iterator]’
/home/p/MyApps/stlpp/stlpp.h:532:53: instantiated from ‘TrueIterContainer<C>::TrueIterContainer(C2&) [with C2 = Upp::InArray<Upp::Vector<int> >, C =
Upp::InArray<Upp::Vector<int> >]’
/home/p/MyApps/stlppTest/stlppTest.cpp:17:27: instantiated from ‘void testIterContainers() [with C = Upp::InArray<Upp::Vector<int> >]’
/home/p/MyApps/stlppTest/stlppTest.cpp:40:46: instantiated from ‘void test() [with V = Upp::Vector<int>]’
/home/p/MyApps/stlppTest/stlppTest.cpp:50:21: instantiated from here
/home/p/upp/uppsrc/Core/InVector.hpp:755:2: error: no match for ‘operator=’ in ‘it.Upp::InArray<Upp::Vector<int> >::ConstIterator::it = ((const Upp::I
nArray<Upp::Vector<int> >*)this)->Upp::InArray<Upp::Vector<int> >::iv.Upp::InVector<T>::End [with T = Upp::Vector<int>*]()’
/home/p/upp/uppsrc/Core/InVector.hpp:755:2: note: candidate is:
/home/p/upp/uppsrc/Core/InVector.h:200:20: note: Upp::InVector<Upp::Vector<int>*>::Iterator& Upp::InVector<Upp::Vector<int>*>::Iterator::operator=(con
st Upp::InVector<Upp::Vector<int>*>::Iterator&)
/home/p/upp/uppsrc/Core/InVector.h:200:20: note: no known conversion for argument 1 from ‘Upp::InVector<Upp::Vector<int>*>::ConstIterator’ to ‘const
Upp::InVector<Upp::Vector<int>*>::Iterator&’
/home/p/upp/uppsrc/Core/InVector.hpp: In member function ‘void Upp::InArray<T>::SetBegin(Upp::InArray<T>::ConstIterator&) const [with T = Upp::Vector<
int>]’:
/home/p/upp/uppsrc/Core/InVector.h:331:65: instantiated from ‘Upp::InArray<T>::Iterator Upp::InArray<T>::Begin() [with T = Upp::Vector<int>]’
/home/p/upp/uppsrc/Core/InVector.h:345:2: instantiated from ‘Upp::InArray<T>::iterator Upp::InArray<T>::begin() [with T = Upp::Vector<int>, Upp::InA
rray<T>::iterator = Upp::InArray<Upp::Vector<int> >::Iterator]’
/home/p/MyApps/stlpp/stlpp.h:532:53: instantiated from ‘TrueIterContainer<C>::TrueIterContainer(C2&) [with C2 = Upp::InArray<Upp::Vector<int> >, C =
Upp::InArray<Upp::Vector<int> >]’
/home/p/MyApps/stlppTest/stlppTest.cpp:17:27: instantiated from ‘void testIterContainers() [with C = Upp::InArray<Upp::Vector<int> >]’
/home/p/MyApps/stlppTest/stlppTest.cpp:40:46: instantiated from ‘void test() [with V = Upp::Vector<int>]’
/home/p/MyApps/stlppTest/stlppTest.cpp:50:21: instantiated from here
/home/p/upp/uppsrc/Core/InVector.hpp:749:2: error: no match for ‘operator=’ in ‘it.Upp::InArray<Upp::Vector<int> >::ConstIterator::it = ((const Upp::I
nArray<Upp::Vector<int> >*)this)->Upp::InArray<Upp::Vector<int> >::iv.Upp::InVector<T>::Begin [with T = Upp::Vector<int>*]()’
/home/p/upp/uppsrc/Core/InVector.hpp:749:2: note: candidate is:
/home/p/upp/uppsrc/Core/InVector.h:200:20: note: Upp::InVector<Upp::Vector<int>*>::Iterator& Upp::InVector<Upp::Vector<int>*>::Iterator::operator=(con
st Upp::InVector<Upp::Vector<int>*>::Iterator&)
/home/p/upp/uppsrc/Core/InVector.h:200:20: note: no known conversion for argument 1 from ‘Upp::InVector<Upp::Vector<int>*>::ConstIterator’ to ‘const
Upp::InVector<Upp::Vector<int>*>::Iterator&’
stlppTest: 1 file(s) built in (0:05.84), 5848 msecs / file, duration = 5855 msecs, parallelization 0%
minimal testing program is
struct InArrayDebug
{
InArray<int> c;
InArray<int>::ConstIterator end() const {return c.end();}
InArray<int>::ConstIterator begin() const {return c.begin();}
};
the problem with segtor is
/home/p/MyApps/stlpp/stlpp.h:75:2: note: no known conversion for argument 2 from ‘Upp::Segtor<Upp::Vector<int>, 16>::iterator {aka Upp::IIterator<Up
p::Segtor<Upp::Vector<int>, 16> >}’ to ‘Upp::ConstIIterator<Upp::Segtor<Upp::Vector<int>, 16> >’
please note, I haven't updated svn yet,
returns 5977 as the revision number on googlecode.
[Updated on: Tue, 16 April 2013 20:47] Report message to a moderator
|
|
|
Re: stl-compatibility [message #39720 is a reply to message #39674] |
Sat, 20 April 2013 18:59 |
|
mirek
Messages: 14038 Registered: November 2005
|
Ultimate Member |
|
|
It should be now fixed, except Segtor, which is totally obsolete...
This now compiles:
#include <Core/Core.h>
using namespace Upp;
template <class T>
void Check()
{
T a;
std::includes(a.begin(), a.end(), a.begin(), a.end());
const T& b = a;
std::includes(b.begin(), b.end(), b.begin(), b.end());
}
CONSOLE_APP_MAIN
{
Check< Vector<int> > ();
Check< Array<int> > ();
Check< BiVector<int> > ();
Check< BiArray<int> > ();
Check< Index<int> > ();
Check< ArrayIndex<int> > ();
Check< VectorMap<int, int> > ();
Check< ArrayMap<int, int> > ();
Check< InVector<int> > ();
Check< InArray<int> > ();
Check< SortedIndex<int> > ();
Check< SortedVectorMap<int, int> > ();
Check< SortedArrayMap<int, int> > ();
}
|
|
|
Goto Forum:
Current Time: Fri Sep 20 08:08:21 CEST 2024
Total time taken to generate the page: 0.03676 seconds
|
|
|