#include <deque>
#include <utility>
#include <algorithm>
-#include <iterator>
#include <stdint.h>
/* sizeof(E) tiene que ser 2*sizeof(N); y son los tipos nativos con los cuales
* se haran las operaciones mas basicas. */
+template < typename N, typename E >
+struct number;
+
+template < typename N, typename E >
+std::ostream& operator<< (std::ostream& os, const number< N, E >& n);
+
template < typename N = uint32_t, typename E = uint64_t >
struct number
{
const_reverse_iterator rbegin() const { return chunk.rbegin(); }
const_reverse_iterator rend() const { return chunk.rend(); }
+ // Friends
+ template < typename NN, typename EE >
+ friend std::ostream& operator<< (std::ostream& os, const number< NN, EE>& n);
+
private:
// Atributos
chunk_type chunk;
std::ostream& operator<< (std::ostream& os, const number< N, E >& n)
{
// FIXME sacar una salida bonita en ASCII =)
- std::copy(n.begin(), n.end(), std::ostream_iterator< N >(os, " "));
+ for (typename number< N, E >::const_iterator i = n.chunk.begin();
+ i != n.chunk.end(); ++i)
+ os << std::hex << *i << " ";
return os;
}
int main()
{
-#if 0
- //unsigned buf[5] = { 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0 };
+#if 1
+ unsigned buf[5] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0 };
//unsigned buf[3] = { 0xffffffff, 0x1, 0 };
- number< unsigned > nu = 0xffffffff;
+ number<> nu(buf, 4);
//number< unsigned > nu2(nu);
- number< unsigned > nu2 = 1u;
+ number<> nu2 = 1u;
std::cout << "nu = " << nu << "\n\n";
std::cout << "nu2 = " << nu2 << "\n\n";
std::cout << "nu + nu2 = " << nu + nu2 << "\n\n";
#endif
+#if 0
number< unsigned > nu = 0xffffffff;
std::cout << "nu = " << nu << "\n\n";
nu << 5;
std::cout << "nu = " << nu << "\n\n";
+#endif
return 0;