Sign in to follow this  
jeff0

The Best C/C++ Forum?

Recommended Posts

This might be what you're looking for somewhat.

Anyway, you could always just work with a bunch of tutorials, and then ask questions here. Most of us are pretty smart, at least with programming in C/C++.

Share this post


Link to post
Share on other sites
Quote:

Where can I find the best forum for C/C++ -specific questions?


Right here. True this may not be a c/c++ specfic forum but this forum has just about as many c++ programmers as anyother. Also you get replies damn near instantly.

Share this post


Link to post
Share on other sites
Quote:
Original post by ForeverNoobie
Quote:

Where can I find the best forum for C/C++ -specific questions?


Right here. True this may not be a c/c++ specfic forum but this forum has just about as many c++ programmers as anyother. Also you get replies damn near instantly.


Speak for yourself. I'm lucky enough to be awake when most of you guys are asleep. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Endar
This might be what you're looking for somewhat.

Anyway, you could always just work with a bunch of tutorials, and then ask questions here. Most of us are pretty smart, at least with programming in C/C++.


Ok, if you are so smart then maybe you can answer this question I posted some week or two ago on gamedev.

The reason I want a C/C++ only forum is because I am already very experienced in C/C++ and I am probably above the level of any pure C/C++ tutorial that exists.

Share this post


Link to post
Share on other sites
Quote:
Original post by ForeverNoobie
Quote:

Where can I find the best forum for C/C++ -specific questions?


Right here. True this may not be a c/c++ specfic forum but this forum has just about as many c++ programmers as anyother. Also you get replies damn near instantly.


I don't want useless replies, no matter if they are instant or not ;)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I'm sorry, but looking at you own Standard Template Library code (from your site), you don't appear to be "above the level of any pure C/C++ tutorial that exists".

jsh_list.h

/*
Copyright (c) 2003-2006, Jesper Öqvist

[comments]
Simple unidirectional list class.

[license]
See license.txt

[created] 2003-02-28
[updated] 2004-07-10
added jsh::list::iterator::null_pointer
[updated] 2004-07-30
added jsh::list::find_first
[updated] 2005-12-02
changed empty() to is_empty()
[updated] 2005-12-06
added pop_back()
*/


#ifndef jshList_h
#define jshList_h

#include <jsh_base.h>

#pragma warning(disable: 4284)

namespace jsh{

template <class _t>
class list
{
struct _node
{
_t _value;
_node* _next;

_node() {}
_node(const _node& _a) {*this = _a;}
_node& operator=(const _node& _a) {_value = _a._value;_next = _a._next;}
~_node() {}
};
_node* _front;
_node* _back;
ulong _size;

public:
list<_t>(): _front(NULL), _back(NULL), _size(0) {}
list<_t>(const list<_t>& _a): _front(NULL), _back(NULL), _size(0) {*this = _a;}
list<_t>& operator=(const list<_t>& _a){
clear();
_node* _tmp = _a._front;
while (true){
if (_tmp == NULL) return *this;
push_back(_tmp->_value);
_tmp = _tmp->_next;
}
}
~list<_t>() {clear();}

class iterator
{
friend class list<_t>;
protected:
mutable _node* _pointer;

const iterator& operator--() const {/*NOT a bidirectional iterator*/}
const iterator operator--(int) const {/*NOT a bidirectional iterator*/}
iterator& operator--() {/*NOT a bidirectional iterator*/}
iterator operator--(int) {/*NOT a bidirectional iterator*/}

public:
iterator(): _pointer(NULL) {}
iterator(const iterator& _a) {*this = _a;}
iterator(_node*const& _a): _pointer(_a) {}
~iterator() {}

const iterator& operator=(const iterator& _a) const {_pointer = _a._pointer;return *this;}
const iterator& operator=(const _node*const& _a) const {_pointer = _a;return *this;}
const iterator& operator=(_node*& _a) {_pointer = _a;return *this;}

const _t& operator*() const {return _pointer->_value;}
const _t* operator->() const {return &_pointer->_value;}
_t& operator*() {return _pointer->_value;}
_t* operator->() {return &_pointer->_value;}
const iterator& operator++() const {_pointer = _pointer->_next;return *this;}
const iterator operator++(int) const {iterator _tmp(*this);++(*this);return _tmp;}
iterator& operator++() {_pointer = _pointer->_next;return *this;}
iterator operator++(int) {iterator _tmp(*this);++(*this);return _tmp;}
bool operator==(const iterator& _a) const {return (_pointer == _a._pointer);}
bool operator!=(const iterator& _a) const {return (_pointer != _a._pointer);}
bool operator==(const _node*const& _a) const {return (_pointer == _a);}
bool operator!=(const _node*const& _a) const {return (_pointer != _a);}
friend bool operator==(const _node*const& _a, const iterator& _b) {return (_a == _b._pointer);}
friend bool operator!=(const _node*const& _a, const iterator& _b) {return (_a != _b._pointer);}

//is the iterator pointing at nothing?
bool null_pointer() const {return (_pointer == NULL) ? true : false;}
};

void push_front(const _t& _a);//put value at front
void push_back(const _t& _a);//put value at back
void pop_front();//remove front element
void pop_back();//remove last element
const iterator begin() const {return iterator(_front);}//constant iterator
iterator begin() {return iterator(_front);}//non-constant iterator
const _t& front() const {return _front->_value;}//consant reference
_t& front() {return _front->_value;}//non-constant reference
const iterator end() const {return iterator(_back);}//constant iterator
iterator end() {return iterator(_back);}//non-constant iterator
const _t& back() const {return _back->_value;}//constant reference
_t& back() {return _back->_value;}//non-constant reference
ulong size() const {return _size;}//size of list
ulong length() const {return _size;}//size of list
bool is_empty() const {return (!_size);}//is list empty?
void clear() {while (!is_empty()) pop_front();}//erase all the contents of the list
void remove(const _t& _a);//remove all elements with values equal to argument
void erase(iterator& _a);//erases iterator from list
void insert(iterator& _a, const _t& _b);//insert _b in front of _a
void insert_after(iterator& _a, const _t& _b);//insert _b after _a
void swap(list<_t>& _a){//swaps this list with argument
_node* _tmp;_tmp = _front;_front = _a._front;_a._front = _tmp;
_tmp = _back;_back = _a._back;_a._back = _tmp;
ulong _tmp2 = _size;_size = _a._size;_a._size = _tmp2;}
void reverse(){//reverses order of elements
list<_t> _new;
while (!is_empty()){
_new.push_front(front());
pop_front();}
swap(_new);}
iterator find_first(const _t& _a){//finds first element matching argument
iterator _it = begin();
while (!_it.null_pointer()){
if (*_it == _a) return _it;
_it++;
}
return iterator(NULL);
}
};

template <class _t>
void list<_t>::push_front(const _t& _a)
{
if (!is_empty())
{
_node* _new = new _node;
_new->_next = _front;
_front = _new;
}
else
{
_front = new _node;
_front->_next = NULL;
_back = _front;
}
_front->_value = _a;
_size++;
}

template <class _t>
void list<_t>::push_back(const _t& _a)
{
if (!is_empty())
{
_back->_next = new _node;
_back = _back->_next;
}
else
{
_front = new _node;
_back = _front;
}
_back->_value = _a;
_back->_next = NULL;
_size++;
}

template <class _t>
void list<_t>::pop_front()
{
if (is_empty()) return;
if (_front == _back)
{
delete _front;
_front = _back = NULL;
}
else
{
_node* _tmp = _front->_next;
delete _front;
_front = _tmp;
}
_size--;
}

template <class _t>
void list<_t>::pop_back()
{
if (is_empty()) return;
if (size() == 1)
{
clear();
return;
}
_node* _tmp = _front;
while (_tmp->_next != _back)
{
_tmp = _tmp->_next;
}
delete _back;
_back = _tmp;
_back->_next = NULL;
}

template <class _t>
void list<_t>::remove(const _t& _a)
{
_node* _tmp = _front;
_node* _tmp2 = _tmp;
while (true)
{
if (_tmp == NULL) return;
if (_tmp->_value == _a)
{
if (_tmp == _front)
{
pop_front();
if (is_empty()) return;
_tmp = _tmp2 = _front;
_tmp = _tmp->_next;
}
else
{
_tmp2->_next = _tmp->_next;
if (_tmp == _back) _back = _tmp2;
delete _tmp;
_tmp = _tmp2->_next;
_size--;
}
continue;
}
_tmp2 = _tmp;
_tmp = _tmp->_next;
}
}

template <class _t>
void list<_t>::erase(iterator& _a)
{
_node* _tmp = _front;
_node* _tmp2 = _tmp;
while (true)
{
if (_tmp == NULL) return;
if (_tmp == _a)
{
if (_tmp == _front)
{
pop_front();
_a = _front;
}
else
{
_tmp2->_next = _tmp->_next;
if (_tmp == _back) _back = _tmp2;
delete _tmp;
_a = _tmp2->_next;
_size--;
}
return;
}
_tmp2 = _tmp;
_tmp = _tmp->_next;
}
}

template <class _t>
void list<_t>::insert(iterator& _a, const _t& _b)
{
_node* _tmp = _front;
_node* _tmp2 = _tmp;
while (true)
{
if (_tmp == NULL) return;
if (_tmp == _a)
{
if (_tmp == _front)
push_front(_b);
else
{
_tmp2->_next = new _node;
_tmp2 = _tmp2->_next;
_tmp2->_next = _tmp;
_tmp2->_value = _b;
_size++;
}
return;
}
_tmp2 = _tmp;
_tmp = _tmp->_next;
}
}

template <class _t>
void list<_t>::insert_after(iterator& _a, const _t& _b)
{
_node* _tmp = _front;
while (true)
{
if (_tmp == NULL) return;
if (_tmp == _a)
{
if (_tmp == _back)
push_back(_b);
else
{
_node* _tmp2 = _tmp->_next;
_tmp->_next = new _node;
_tmp = _tmp->_next;
_tmp->_next = _tmp2;
_tmp->_value = _b;
_size++;
}
return;
}
_tmp = _tmp->_next;
}
}

};

#pragma warning(default: 4284)

#endif//jshList_h

Share this post


Link to post
Share on other sites
Quote:
Original post by jeff0
Quote:
Original post by Endar
This might be what you're looking for somewhat.

Anyway, you could always just work with a bunch of tutorials, and then ask questions here. Most of us are pretty smart, at least with programming in C/C++.


Ok, if you are so smart then maybe you can answer this question I posted some week or two ago on gamedev.

The reason I want a C/C++ only forum is because I am already very experienced in C/C++ and I am probably above the level of any pure C/C++ tutorial that exists.


As rip_off already helpfully answered, any solution to the question you have linked to would be implementation dependant, so posting on a pure C or C++ forum would be unlikely to help.

PS I appreciate you do not want useless replies like mine but unfortunately this is a public forum so you will just have to put up with it.

Paul

Share this post


Link to post
Share on other sites
After seening how fast this thread went off-topic I guess I'll just find one for myself.

Don't get me wrong now, I'm sure there are lots of good programmers here at gamedev that might be able to help me, but this is hardly the best c/c++ forum - mainly due to the fact that it isn't a c/c++ forum.

Share this post


Link to post
Share on other sites
You might want to check out the comp.lang.c++ group, and subgroup (moderated). But a word of advice - be careful about the level of arrogance that is beginning to creep into some of your posts - judging by your "standard template library" implementation the AP mentioned your level of skill is nowhere near as high as you think it is. I'm not saying you're not competent, just that you are definitely not "very experienced in C/C++ and I am probably above the level of any pure C/C++ tutorial that exists".

Σnigma

Share this post


Link to post
Share on other sites
Quote:
Original post by jeff0
After seening how fast this thread went off-topic I guess I'll just find one for myself.

Don't get me wrong now, I'm sure there are lots of good programmers here at gamedev that might be able to help me, but this is hardly the best c/c++ forum - mainly due to the fact that it isn't a c/c++ forum.


I don't want to offend you (despite the fact that I find you offensive, mostly because I feel bad when some guy just tell me that the quality of the help I can give is not good enough; of course, it can be better - of course, I am often wrong, but I believe that most of the time my help is valuable enough), but most valid questions get very valid answers here - ie the kind of answers you'll get on comp.lang.c or comp.lang.c++, or in the boost mailing list. There are some great individuals here, and they took their own time to help you.

That said, regarding your other thread, you'll notice that rip-off (the first answer, which came 5 minutes after you posted your question) is the correct one (ie not standard way (mainly because the inner working of the C standard buffered io functions is a implementation detail), so the best you can do is using what you already did: educated guess, with compiler/system dependant defines to provide multiple implementations of your stuff). What else to say? Kernigan would not help more.

Quote:
Original post by jeff0
I don't want useless replies, no matter if they are instant or not ;)

The only solution I see to to avoid posting.

@AP: what's wrong with this code? It's not perfect (the push_* and the remove function can be done in a better way, end() is not standard compliant, the allocator<> is missing - as well as some list methods (splice, merge, ...)), but it's not Teh Bad. There are some weaknesses, but I still believe jeff0 when he says that he is above most of the C/C++ tutorial that are found on the net.

Regards,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Emmanuel Deloget
@AP: what's wrong with this code? It's not perfect (the push_* and the remove function can be done in a better way, end() is not standard compliant, the allocator<> is missing - as well as some list methods (splice, merge, ...)), but it's not Teh Bad. There are some weaknesses, but I still believe jeff0 when he says that he is above most of the C/C++ tutorial that are found on the net.

Regards,

I didn't mean that that particular file contained serious errors, I just think the general feel of the library feels a bit hackish and not-so-thoroughly implemented (I gave jsh_list.h as an example on how the syntax looks). I agree that he has more skills than the avarage C/C++ programmer on the net, but not enough to nominate himself as some kind of C/C++ guru and definitely not enough to judge this forum as incompetent (which upset me the most).

Share this post


Link to post
Share on other sites
Geez, I didn't think you Gamedev guys would be so touchy! I'm not trying to be arrogant but it's not a fun thing to hear after slighly more than six years in C++ that you should maybe read tutorials.

And to those who have looked at my template list class: there is more to my programming than that. Honestly.

I will not go around judging people by single pieces of their work that even might have been done a conciderable while ago, but just for your information I've made my own webserver, graphplotter, C-like script parser and TTF parser too. More than enough to have the right to call myself experienced.

Share this post


Link to post
Share on other sites
Quote:
Original post by jeff0
Geez, I didn't think you Gamedev guys would be so touchy! I'm not trying to be arrogant but it's not a fun thing to hear after slighly more than six years in C++ that you should maybe read tutorials.

And to those who have looked at my template list class: there is more to my programming than that. Honestly.

I will not go around judging people by single pieces of their work that even might have been done a conciderable while ago, but just for your information I've made my own webserver, graphplotter, C-like script parser and TTF parser too. More than enough to have the right to call myself experienced.


I hope this thread has had its day but just before I go, how exactly were we supposed to infer from

Quote:

Where can I find the best forum for C/C++ -specific questions?


that you had six years experience with C++? This is by far the best programming forum on the internet, C++ notwithstanding, because of the absense of ego by the vast majority and the pouncing upon of the minority that deviate from this.

There. Said.

Paul

Share this post


Link to post
Share on other sites
i'll agree with Enigma and suggest that newsgroups are the way to go, especially the one he mentioned. i've posted a few questions there b4 and almost always PJ Plauger (the guy who wrote MS's STL imp) answered them. some cool no-nonsense people there.

Share this post


Link to post
Share on other sites
Though I tend to read these boards more often I've also found the codeguru forums useful as well. The C++ board(s) are here

[Edited by - Tsurumaru on May 25, 2006 2:54:52 PM]

Share this post


Link to post
Share on other sites
Umm. I would call you experienced. In fact, much more knoledgable than me. But may I ask *why* (and I really mean *why*) your string is implemented linked list??? You also have many functions copying stuff rather than returning references (operator[]), as well as the fact that operator[] actually iterates over every single character to find the char.

Anyways, I would just go posting C++ questions here or in the For Beginners if it's something I haven't played around with before...

Share this post


Link to post
Share on other sites
Quote:
Original post by EasilyConfusedthe absense of ego by the vast majority and the pouncing upon of the minority that deviate from this.


I think that this thread proves that us at gamedev certainly do have egos. We just like to hide them, until they are broken.

Share this post


Link to post
Share on other sites
Quote:
Original post by Enigma
You might want to check out the comp.lang.c++ group, and subgroup (moderated).


I second that. These guys are pros, respond very quickly, and are very enthusiastic about helping you find solutions, and the Right Thing To Do, and all other possibilities.

Just make sure you stay on-topic (c++) and don't ask OS/API-dependent questions.

[Edited by - discman1028 on May 24, 2006 11:02:59 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Whilst not a c++ forum the programming forum on linux questions is very good.
http://www.linuxquestions.org/questions/forumdisplay.php?f=9

Share this post


Link to post
Share on other sites
Quote:

*****snip*****
may I ask *why* (and I really mean *why*) your string is implemented linked list??? You also have many functions copying stuff rather than returning references (operator[]), as well as the fact that operator[] actually iterates over every single character to find the char.
*****snip*****


agi_shi, I chose to use a linked list because that cuts some time when appending strings. Appending was also the primary purpose I wrote that class for. Using memcopy can get tedious, trust me :)

The indexing operator [] is not supposed to be used as the primary means of indexing into the string.. I know it is terriby slow but I put it in there when I discovered that I needed it for some quick soulutions. The good soulution for indexing into the string (if you plan on doing it several times) is by getting a buffer with jsh::string::get_buffer().

Also, there is some copying of elements in the functions - I have tried to avoid this but in some cases I had to take into concideration that the string could be declared with a const qualifier and returning a reference would discard that qualifier (or: couldn't return reference to temporary object). In the case of the indexing operator I must have just forgotten that I might want to return a reference... as I said, it was a quick soulution.

Share this post


Link to post
Share on other sites
As someone already said in this thread, you can find the best pure C++ help in the newsgroups comp.lang.c++ and comp.lang.c++.moderated. In the latter groups guys like Herb Sutter, Francis Glassborow and Bjarne Stroustrup may reply to your thread. I don't think you can get much better than that.

Share this post


Link to post
Share on other sites
Ok, then I'll be shure to check out the comp.lang... thanks for the info!

I'm not really in to newsgroups (or forums), this will be the first time I use one of those.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by jeff0
Quote:

*****snip*****
may I ask *why* (and I really mean *why*) your string is implemented linked list??? You also have many functions copying stuff rather than returning references (operator[]), as well as the fact that operator[] actually iterates over every single character to find the char.
*****snip*****


agi_shi, I chose to use a linked list because that cuts some time when appending strings. Appending was also the primary purpose I wrote that class for. Using memcopy can get tedious, trust me :)

The indexing operator [] is not supposed to be used as the primary means of indexing into the string.. I know it is terriby slow but I put it in there when I discovered that I needed it for some quick soulutions. The good soulution for indexing into the string (if you plan on doing it several times) is by getting a buffer with jsh::string::get_buffer().

Also, there is some copying of elements in the functions - I have tried to avoid this but in some cases I had to take into concideration that the string could be declared with a const qualifier and returning a reference would discard that qualifier (or: couldn't return reference to temporary object). In the case of the indexing operator I must have just forgotten that I might want to return a reference... as I said, it was a quick soulution.


Horrible reason to implement a string as a linked list. There is no reason to do such stupid crap.

std::string s;
s.reserve(1024);
Now append tons of stuff and no re-allocation unless you get to some huge strings, in which case increase your reserve. It's incredibly trivial to add such functionality in a custom string class as well, and maintain the contiguous memory buffer that the whole programming world pretty much expects.

A linked list implementation is terrible in terms of memory usage, cache usage, and memory fragmentation. Nobody would use that kind of implementation in any serious app. It offers nothing but slowness and extra unnecessary complexity.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this