[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
reinterpret_cast
From: |
Piotr Sawuk |
Subject: |
reinterpret_cast |
Date: |
13 May 2009 23:40:46 GMT |
I have found an application for this obscure operation, but
unfortunately it doesn't work. how would you suggest to implement
the following header-file to avoid these errors in gcc-4.1.2:
infinilife.h:56: error: invalid cast from type
'__gnu_cxx::__normal_iterator<const hull8conv::forwards*, std::vecto
r<hull8conv::forwards, std::allocator<hull8conv::forwards> > >' to type
'__gnu_cxx::__normal_iterator<const unsigned int*, std::vector<
unsigned int, std::allocator<unsigned int> > >'
infinilife.h:57: error: invalid cast from type
'__gnu_cxx::__normal_iterator<const hull8conv::forwards*, std::vecto
r<hull8conv::forwards, std::allocator<hull8conv::forwards> > >' to type
'__gnu_cxx::__normal_iterator<const unsigned int*, std::vector<
unsigned int, std::allocator<unsigned int> > >'
#include <Core/Core.h>
#include <numeric>
#include <vector>
enum Direction {R=0,DR,D,DL,L,UL,U,UR};//clockwise
Direction operator+(Direction d,int i) {return (Direction)((d+i)&7);}
Direction& operator++(Direction& d) {return (++d&8?(d=R):d);}
Direction operator++(Direction& d,int)
{
Direction out=d;
if(++d&8)d=R;
return out;
}
class hull8convex
{
union forwards
{
uint64 b;//for raw-copy
uint32 s[2];
};
template<bool BRACK>
struct addBrack : std::binary_function<int,forwards,int>
{
int operator()(const int i,const forwards f) const {return i+f.s[BRACK];}
};
typedef std::vector<forwards> sizevector;
typedef std::vector<uint32> uintoverride;
int tops[8]; //index of type Direction
sizevector forwards[8]; //forwards[i] between tops[i] and tops[i+1]
public:
int height(Direction d) const
{
int out=std::accumulate(forwards[d+4].begin(),forwards[d+4].end(),
0,addBrack<0>());
const Direction stop=d+7;
for(Direction i=d+5;i!=stop;out+=tops[i++])
std::accumulate(reinterpret_cast<uintoverride::const_iterator>(
forwards[i].begin()), //line #56
reinterpret_cast<uintoverride::const_iterator>(
forwards[i].end()), //line #57
out);
return std::accumulate(forwards[stop].begin(),forwards[stop].end(),
out,addBrack<1>());
}
};
--
Better send the eMails to netscape.net, as to
evade useless burthening of my provider's /dev/null...
P
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- reinterpret_cast,
Piotr Sawuk <=