I would like to use Boost Phoenix to generate a lambda function for use in a std::find_if operation on a structure that contains reference-type members. A contrived example is as follows:
 struct MyStruct 
 { 
  MyStruct() : x(0) {} 
  int& x;
  };
 std::vector<MyStruct> AllStructs;
 // Search the array for an element for which x == 5...
            
           
          
            
            I'm newbie. Pointer make my crazy T_T.
Now, I'm do the socket programming project.
This is my code.
typedef struct {
        char *ip[INET6_ADDRSTRLEN];
        char *username[20];
        time_t login_time;
        enum client_state client_state;
        int no_login;
    } Client;
    Client client[max_connections] = {}; // set to nu...
            
           
          
            
            
  Possible Duplicate:
  What is the difference between using a struct with two fields and a pair?  
Dear all,
I have a little question about pairs and struct. Is there any advantage to use a std::pair instead of a struct with two cells ?
I have used pairs for a while but the main problem is readability :
If you want to represent fo...
            
           
          
            
            This is linked to my previous post
Wher I created a Struct :
struct buffer
{
    char ProjectName[20];
       char ProjectID[20];
};
Now while I am trying to assign values to it:
buffer buf;
buf.ProjectID = "3174";
buf.ProjectName = "NDS";
I am getting this error:
error C2440: '=' : cannot convert from 'char [5]' to 'char [20]'
...
            
           
          
            
            I'm writing a game that has a huge 2D array of "cells". A cell takes only 3 bytes. I also have a class called CellMap, which contains the 2D array as a private field, and provides access to it via a public indexer.
Profiling showed that a performance problem is caused by garbage collection of too many Cell objects. So I decided to make ...
            
           
          
            
            Hi,
I'm currently working on an FTP client written in C, and it's working pretty good. I was successful in writing a function that connects to an FTP server and logs in with a username or password, but I'm having a problem with returning errors. I have setup a struct FTPError {}; with 3 fields:
int An error code
int An FTP error domain...
            
           
          
            
            I have a struct called Base64String which basically does implicit conversion between a string and a byte[]
It's working quite well in the library, but here's the oddity...
When I have a webservice, that returns the value as Base64String
    [WebMethod]
    public Base64String GetBase64String(string input)
    {
        return input;
 ...
            
           
          
            
            I'm using Coldfusion. I want to concatenate two strings into the same struct key, but I keep getting an error of "can't convert x into a boolean."
For example:
<cfset myStruct.string1 = nodes[1].string1.XmlText>
<cfset mystruct.string2 = nodes[1].string2.XmlText>
Neither of the following works 
<cfset myStruct.concatendatedSring = n...
            
           
          
            
            for the reportlab library there is a module 
utils.py, and within this module a class
class ImageReader(object):
I was expecting to use this class to get RGB style data of integers between 0 and 255 but instead my code returns the following 
(1718461541,)
for each print line below
import struct
filename = "pakistan.jpg"
imageObj = u...
            
           
          
            
            My gut reaction is no, because managed and unmanaged memory are distinct, but I'm not sure if the .NET Framework is doing something with Marshaling behind the scenes.
What I believe happens is:
When getting a struct from my unmanaged DLL, it is the same as making that call gets an IntPtr and then uses it and the Marshal class to copy th...
            
           
          
            
            If I want to store some strings or matrices of different sizes in a single variable, I can think of two options: I could make a struct array and have one of the fields hold the data,
structArray(structIndex).structField
or I could use a cell array,
cellArray{cellIndex}
but is there a general rule-of-thumb of when to use which data ...
            
           
          
            
            I thought I understood how C/C++ handled struct member alignment. But I'm getting strange results for a particular arrangement in Visual Studio 2008 and 2010.
Specifically, I'm finding that a struct consisting of a char, short, and char is compiled into a 6-byte struct, even with 4- or 8-byte packing enabled. I am at a loss as to why th...
            
           
          
            
            By way of explanation, take this value type in C#:
struct ObjRef
{
    public object Value;
    public ObjRef(object value) { Value = value; }
}
I can imagine an object graph where there are two boxed instances of this type, each holding a reference to the other. This is what I mean by a reference-cycle with only value-types.
My ques...
            
           
          
            
            I'm trying to implement linked-lists with c struct, I use malloc to allocate a new node then allocate space for value, so I've been thinking how to free the structure once I'm done with them, my structure looks like this:
typedef struct llist {
     char *value;
     int line;
     struct llist *next;
} List;
I have a function that wa...
            
           
          
            
            With this code (just a class of test):
typedef unsigned short UInt16;
template<class T>
class CClass
{
public:
    SValue* getNewSValue(void);
private:
    typedef struct {
        T *mValue;
        T *next;
        T *previous;
        UInt16 index;
    } SValue;
};
template<typename T>
SValue* CClass<T>::getNewSValue(void)
{
    re...
            
           
          
            
            I am using C++ for an online game server project and I need to store some structs as binary blobs in a MySQL database. I am using RakNet for networking and have tried using its BitStream class to serialize the data but I don't know how to do it right. My question is, how do you turn a structure into a stream of bytes that you can pass in...
            
           
          
            
            New to StackOverflow and new to C. I'm trying to take a struct as a parameter in a function 'add_fields', which adds the first two int fields 'a' and 'b' and puts the result in int field 'c'. Not getting anything from the compiler, so obviously I'm doing something wrong. I just don't know what. Any help would be appreciated. 
    #inclu...
            
           
          
            
            Hi,
I have a little problem in C++ I don't know how to solve.
The first part of the problem is to access an element in a struct via [], or better, to map [] to a subelement.
My struct looks like this:
struct e {
    std::string content;
    std::string name;
    std::map<std::string, std::vector<e> > elements;
};
If I want to access ...
            
           
          
            
            I have a structure:
typedef struct {
   double x,y,z;
} XYZ;
I want to define a function like this:
double CalcDisparity(XYZ objposition, 
                     XYZ eyeposition, 
                     double InterOccularDistance = 65.0)
But I can't seem to find a way to assign a default value to eyeposition.  How can I do this in C++...
            
           
          
            
            How is struct sockaddr different from struct struct sockaddr_un ?
I know that we use these structures in client-server modules,for binding the socket to the socket address.And we use a cast operator for it to accept struct sockaddr_un.
I want to know how different/similar are they,and why the cast operator?
...