To exand what I said in the first post:
Header hdr;
read( reinterpret_cast<u_char*>(hdr) );
// Everything in it's right place now
// use hdr here
That means that the...
Type: Posts; User: drrngrvy
To exand what I said in the first post:
Header hdr;
read( reinterpret_cast<u_char*>(hdr) );
// Everything in it's right place now
// use hdr here
That means that the...
I thought that's exactly what reinterpret_cast does anyway?
I would have thought just having one type (ie. u_char) would make padding a non-issue, but I'm not sure.
No, but my question was more along the lines of: does having anything but a...
Hi all,
I'm wondering about the layout of a class, and what guarantees the standard (C++03) gives about class member layouts.
For instance, if I have a class like:
struct Header {
...
Ok, I've experimented a bit, but I'm still hazy on the correct way to do this. I'd appreciate some advice, as my searches have been mostly fruitless.
template<typename T>
struct traits
{
...
Hi all,
I'm struggling to find information about how to map a file descriptor to port numbers. Something I'm working on requires the program to 'accept()' connections from the file descriptor...
Oops, of course. That wasn't the problem though. I just got it working, but I can't say I understand why one works (Works) and not the other (Broken).
template<typename Type>
struct Traits
{...
Hi all,
I'm having a problem using a typedef'd name in a friend class declaration. What I'm trying is variations on the following:
struct Type
{
typedef OtherType other_type;
In code, I'd do something like this:
void f()
{
tmpl_class<std::string> service; // std::string is just an example
some_class handle(service);
}
I simply want some_class to work with any...
Given a class with a templated member:
template<typename T> class tmpl_class {};
class some_class
{
tmpl_class<T>& tmpl_member;
public:
template<typename T>
some_class(...
Boost::threads is probably the best around though: you don't have every facility of pthreads, but it works on more platforms/compilers than anything else (I think).
Isn't the point of the factory functions so you can do something like:
broken code = make_more_broken(42); // template arg of code automatically deduced
Will that not work?
I feared so. :( Thanks Noir.
Hi all,
I just discovered that class template arguements are never implicitly deduced from their constructor arguements. Am I correct in thinking that the following code won't work (as I don't...
I'm in a situation where I could save copying some memory if I could use a std::vector. The question is, what's the difference between, for instance, a std::vector<char> and a std::string? As far as...
Sorry about the late reply.
The idea does go against seperation of code, but I prefer the idea of having a library that doesn't need to be linked with to work. It's more just for learning though....
Ok, thanks all for clearing that up. I found this, which explains a lot. I was just trying to figure a way of getting boost.asio to accept from STDIN. I still haven't got it, but I'll keep looking....
Sorry, I meant network port. I'm aware that file descriptors map back to anything else, but what about the other way around? What does 127.0.0.1:0 mean? It's port 0 on the loopback, but is that stdin...
This is probably a painfully basic question, but these are usually the hard ones to google for. I know on linux that STDIN has a file descriptor of 0, but does that bear any relevance to the port...
You could just write to and read from the file in binary mode (set the std::ios::binary option when you open the file). Would that do?
Thanks for the reply, but what you're saying to do is the only way I know to do that. The thing I'm wondering is how you implement the declaration of, in your example, Foo::s_value without having a...
I was wondering if there's a way around having to declare static variables only once when writing classes which are just in header files. I didn't think it could be done, but looking around the boost...
Ah, ok. I was actually under the impression (for silly reasons, apparently) that it was the opposite of the global namespace. Oops. Thanks for the reply.
Just a simple one (that's hard to search for answers to), basically just the title.
What exactly happens when there isn't a namespace in front of the '::'? Is it to do with the current namespace?...
You should give the struct a constructor that initialises its members in an initialisation list, then use something like this:
struct s
{
s( const int m1_, const int m2_ ) : m1(m1_) ,...