?

Log in

 

Advanced C++ Community

About Recent Entries

Boost backward compatibility. Mar. 23rd, 2006 @ 06:27 pm
jetsnail
Damn, looks like guys from Boost community don't care 'bout backward compatibility. It was boost 1.31. Today I have downloaded and installed boost version 1.33. Just two points up but my project won't compile. In one of my projects I have simple line of the code to check that two types isn't same. Is it so principial, how to write the same code if both ways are easy? As for me - all the same. But why they don't gives a damn 'bout backward compatibility? I don't want to rewrite and recompile my projects each time boost changed :-\

Was:

#include <boost/mpl/assert_is_same.hpp>

...

BOOST_MPL_ASSERT_NOT_SAME(T, std::string);


Now the same thing should be done by the following:

#include <boost/type_traits/is_same.hpp>
#include
<boost/mpl/assert.hpp>


...

BOOST_MPL_ASSERT_NOT((boost::is_same<T, std::string>));


Mar. 22nd, 2006 @ 03:57 pm
sethx
The D language will soon replace c++. http://www.digitalmars.com/d/

Dylan as well but sadly marketing needs to take a whole new ball game for that to happen.

Comments?

XML with non-English encoding Mar. 19th, 2006 @ 11:07 am
gentlemenka
Does smb know any tip?
When I try to parse XML with greek (for example) symbols, - I receive ASCII symbols instead of text.
How can I get to parser know encoding? (it is UTF-8).
Thanks in advance!

Mar. 17th, 2006 @ 10:49 pm
protozoa
I was trying to write a quine for C++ but couldn't. I still don't get the trick of these. How do you break the cycle of the self referential loop?

Is the MS Development Environment retarded? Feb. 28th, 2006 @ 04:56 pm
th1alb
I just spent 2 hours on the weirdest problem...
As you might have read in my other post, I am currently writing a C++ program under Linux.
I use putty to compile and run my program on the remote machine but edit the code on my local computer.
When I initially double clicked on the .cpp file, it opened it in Microsoft Development Environment, which I thought would work just fine.

To make a long storry short, somewhere along the way, I formatted the code and it put all those cool tabs in.
It also put a tab at this spot here:
findobject(totalbuf,found,"submit\"Xvalue=\"Next \0","\">\0");
The red x marks what used to be a space and definitely needed to be one for my program to work.
It also looked like a space to me. I was going nuts and didn't know what was wrong until i coincidentally noticed everything jump around after the X when moving the whole line.

I also have those in other places, where they don't seem to matter that much.
Just wanted to point out what a little stupid can do to your time.

Inheritance with no Virtual Functions? Feb. 18th, 2006 @ 05:24 pm
tyrdinjer
I am working on a C++ wrapper for CFStringRef and CFMutableStringRef.

Note, all calls that accept a CFStringRef also accept a CFMutableStringRef. But any function that requires a CFMutableStringRef will throw an assert() if a mere CFStringRef is passed in. And no, Apple does not provide a function that lets you test for mutability... :-/

The life span of these structs are determined by a reference count. When the count hits zero, they are actually destroyed. The two functions that increase and decrease the reference count are CFRetain() and CFRelease() respectively.

The primary purpose of the wrapper classes I am writing is to automatically handle the calls to CFRetain() and CFRelease().

Making a class to wrap the CFStringRef is straightforward.

The fun comes into the design for the CFMutableStringRef wrapper class. If I inherit from the CFStringRef wrapper class, it has these traits:

1) No additional data fields.
2) All constructors simply call the base class constructors. They do no additional work.
3) The destructor is empty. The base class destructor does all necessary work.
4) There are no virtual functions.

Essentially, the derived class is providing extended functionality.

So, the big questions is: Do I *need* to worry about at least marking the base destructor as virtual.

Or perhaps the better question is: Is there any hidden traps if I don't declare any virtual functions (beyond losing access to the extended member functions should something be upcasted).

brute force Feb. 15th, 2006 @ 09:18 pm
th1alb
Can you guys give me any pointers, on how I would go about writing a html form brute force application in c++?
This would be used to get into the web interface of my dad's router, who apperantly doesn't know the password and can't find where he notated it.
I would like to forward a port to my server, but don't want to reset the router.

The router is a WR850G (motorola), that has an index.asp with a very simple html form on it.
It shouldn't be too difficult, to write some kind of class, that keeps submitting that form and checks the returned data right?
I would be happy if someone can point me in the right direction or give me any starting points.

ps: don't worry about passwords; i am just gonna keep counting up the letters basically from 00000000 to ZZZZZZZZ until it fits. I'm on the same LAN, so connection is fast and time is irelevant.
pss: i tried a cuppl programs already, AccessDriver seeming the most sufisticated, but had no success, also those programs require a file with passwords and usernames. i would just like to create those while brute forcing; maybe saving the current possition every 500 passwords or so.
Thx a lot.

Jan. 7th, 2006 @ 01:52 am
protozoa
Many "modern" generic programming techniques border on "write only" techniques and threaten to isolate its users. To make generic programming mainstream, as object-oriented programming was made mainstream, we must make template code easier to read, write, and use. Many current uses are too clever for their own good. Good code is simple (relative to what it is trying to do), easy to check, and easy to optimize (i.e., efficient). This implies that a wide range of simple ideas can be expressed simply in C++0x and that the resulting code is uncompromisingly efficient. The former is not the case in C++98—at least not for a sufficiently large range of techniques relying on templates. - Bjarne Stroustrup

Remember the post I made in November of 2003 about Modern C++ Design by Alexandrescu? I think this quote from Stroustrup agrees with me. The quote is from a good article Stroustrup wrote about the new version of C++.

:( Jan. 3rd, 2006 @ 05:38 pm
protozoa
I just got the last issue of the C/C++ User's Journal today. CMP Media has decided to discontinue it. Bastards. It's been a good magazine for the past 8 years that I've been reading it.

Template-based state machine Dec. 21st, 2005 @ 11:22 am
cbradfield
In light of the previous post to this community, I thought I would share my template-based state machine. I'd hardly call this revolutionary, but I thought it might tickle someone's fancy; it is at least an illustration of template recursion. I cannot claim *complete* credit for this code; I got the idea from something in Boost and ended up with this. The code uses the Loki library to implement Typelists, but the necessary code to snag from the library is trivial. Each state machine, of course, is limited by the number of template parameters your compiler supports. What's neat is that after the optimizer and inliner get ahold of the code, it should end up being a jump table:

State MachineCollapse )
Current Mood: snarky
Current Music: Slayer - God Hates Us All

Dec. 21st, 2005 @ 04:17 am
gouda329
I have a question. I'm working on a project and I cannot get two arrays to add together? Any ideas?

Here are the two arrays:
int list1[size] = {8, 4, 6, 10, 3};
int list2[size] = {1, 3, 5, 7, 9};

And then I need to put it in list3 using functions.

I tried doing:
list3[0] = list1[0]+list2[0];
etc..

That did not seem to work. I guess my question is how do I make form into an array. I can add all the numbers together, I just can't make them just add in their respective places.

Thank you!

Carol

Dec. 12th, 2005 @ 10:38 am
derralf
Hi, this isn't too advanced, but I didn't get an answer at cpp. I want to write a graph class template with unspecified vertice and edge objects. I should be able to write functions which return a pointer to some vertex. However, the following code refuses to compile (error at implementation of function choose_random_vertex) :

code (embedded template)Collapse )

I am not experienced with c++. It's probably some referencing convention I am not aware of. Any help is much appreciated.

--R.

Just say No to 'new' Dec. 11th, 2005 @ 03:41 am
protozoa
I find it easy to code in C++ without using new. The standard library makes this very easy; <string> and <vector> are great examples of why new isn't necessary. Too much code uses new when stack allocation and copies work just as well. You can't have a memory leak if you never call new! I've seen many times someone will new something when a function call they want to use requires a pointer, they don't think that they can take the address of a stack variable when the lifetime of the variable is just the function call. In my coding, the only time I need to heap allocate an object is when I need to control the lifetime of the object. I think coding this way is like working in a garbage collected language. There might be lots of temporary/nameless objects, but this should be the same as Java or C#. Passing a std::string to a function or returning one? Use a reference or don't worry about the dynamic memory allocation that goes on behind the scenes. The standard library will handle exception safety much better than I ever could anyway. Don't fear temporaries!

Tracing the grid... Dec. 5th, 2005 @ 03:26 am
th1alb
This is how far I got with my algorithm today:
click hereCollapse )

My first algorithm / Web cam fun Dec. 3rd, 2005 @ 11:52 pm
th1alb
Because this entry is huge, you must click here to see itCollapse )

STL containers and auto_ptr Nov. 16th, 2005 @ 08:39 am
omnifarious

I've recently come to the conclusion that STL container classes should be required to not use copy or assignment unless they really are making a copy of the value. If they're just moving the value, they must use 'swap'.

This would allow STL container classes to be compatible with auto_ptrs, and I'm guessing it would also make them faster. I suspect there are also a much larger class of things they could hold this way too, since they could now efficiently hold objects that are expensive to copy, but cheap to swap.

I also think calling the default constructor on a piece of memory and swapping fits the semantics of what the container is doing with the data much better than copying does.


Nov. 1st, 2005 @ 10:45 pm
corporateshark
How could one determine the number and type of the class constructor's parameters?
To do that for a member function is just a piece of cake:

template
[Error: Irreparable invalid markup ('<class [...] p2,>') in entry. Owner must fix manually. Raw contents below.]

How could one determine the number and type of the class constructor's parameters?
To do that for a member function is just a piece of cake:

template <class T, typename P0, typename P1, typename P2, typename P3>
void BindNativeMethod( void (T::*MethodPtr)(P0, P1, P2, P3) )
{
// we've got 4 params
// use them this way:
std::vector<int> Params;
Params.push_back( TypeToInt<P0>() );
Params.push_back( TypeToInt<P1>() );
Params.push_back( TypeToInt<P2>() );
Params.push_back( TypeToInt<P3>() );
}

template <class T, typename P0, typename P1, typename P2, typename P3, typename P4>
void BindNativeMethod( void (T::*MethodPtr)(P0, P1, P2, P3, P4) )
{
// we've got 5 params
// use them this way:
std::vector<int> Params;
Params.push_back( TypeToInt<P0>() );
Params.push_back( TypeToInt<P1>() );
Params.push_back( TypeToInt<P2>() );
Params.push_back( TypeToInt<P3>() );
Params.push_back( TypeToInt<P4>() );
}

and so on for other members.


But what to do with the class constructors? Is there any way to find out the type of thier arguments? Maybe there's a fundamentally different approach to solve this because it's even impossible to take the address of the constructor?

Something Better than RTTI? Oct. 18th, 2005 @ 04:46 am
tyrdinjer
I was setting up some code where in the main function, there are catches to catch uncaught exceptions. Essentially, they are there to tell me "Hey you missed something!"

Anyway, I was setting up a couple of functions so that I could use Run Time Type Identification (RTTI) to determine what type of exception was caught. Here is the code:
code behind cutCollapse )
Is there a better way than using RTTI?

Oct. 9th, 2005 @ 11:58 pm
docwoodstock
Ok.... what do you think of RogueWave???

HTML generation tools Aug. 29th, 2005 @ 06:11 pm
jedipussytricks
Anybody have a favorite (or hated) C++ library for generating HTML on the fly? Specifically, I'll be creating MIME emails to report custom data to clients. It would be nice to have a distinct separation between content and format, but I wouldn't call that a strong requirement.

Any thoughts on the Mozilla or GNU libraries?
Current Mood: curiouscurious
Top of Page Powered by LiveJournal.com