I like to find a polite way of asking what the host is serving to determine if there will be anything available that fits in to my lifestyle. If I know there will be meat and vegetables, that makes things very easy. If the fare is more simple carb laden, I will eat beforehand and drink water.
Going to a party or to a friends house for dinner is tough because I'm not in control of every single ingredient. I can get a good idea whether or not something is sugar/grain/legume free, but there is no way to be 100%. I like to chalk the not knowing factor up to ignorance is bliss, and quality of life. Let's face it, if I'm going to a party, I want to relax and not be all super uptight about what may or may not be in my food. The other 99% of my life that I'm not at my party will make up for the possible intake of foods that bother me.
I have yet to attend a party or function in which there was absolutely nothing I can eat. So, I find the things I can (carrots, meat, salads, chips, guacamole for example) load up, and move on enjoying the company. If anyone notices my avoidance of anything bread, pasta, bean, or dessert, no one has said anything yet. Imagine that, no one cares what I eat!