|
Regarding std::basic_string, can I use this to build a string character by character using operator += or do I risk this being in O(n^2) time?
|
# ? Dec 14, 2010 23:12 |
|
|
# ? Jun 7, 2024 05:34 |
|
tractor fanatic posted:Regarding std::basic_string, can I use this to build a string character by character using operator += or do I risk this being in O(n^2) time? Why would it be O(n^2)? I can't even imagine what an algorithm for string concatenation would look like that would perform that poorly. Appending a single character is amortized constant time (realistically the buffer may be automatically resized on occasion, pending implementation, which would imply a memcpy).
|
# ? Dec 14, 2010 23:21 |
|
I think he means O(n^2) for the entire process of building the string character-by-character, which is what you'd get if each append did a copy. Anyway, the answer is that while the standard doesn't seem to guarantee that appending a char to a std::basic_string will have amortized constant complexity, I think all implementations do.
|
# ? Dec 14, 2010 23:32 |
|
Harokey posted:Is there a way to create an exception class, that when thrown (and not caught) prints a meaningful error message?
|
# ? Dec 15, 2010 02:10 |
|
Is there a prettier way to dereference this?code:
|
# ? Dec 17, 2010 22:23 |
|
Cylon Dinner Party posted:Is there a prettier way to dereference this? What's wrong with that? If you're doing it a lot in one block you could always create a reference: code:
|
# ? Dec 17, 2010 22:28 |
|
That Turkey Story posted:What's wrong with that? If you're doing it a lot in one block you could always create a reference: Thank you! I find yours easier to read after I bury it in this: code:
|
# ? Dec 18, 2010 00:08 |
|
Hey, I can't for the life of me figure out what's wrong with this program. It's supposed to take a two dimensional array and find the elements that are larger than their neighborscode:
|
# ? Dec 21, 2010 23:09 |
|
It's the line with the break statement. First, break; doesn't do what I think you think it does, and second, you have the condition wrong.
|
# ? Dec 21, 2010 23:33 |
|
Also, just don't use "l" as a variable if at all possible. My first thought when reading that was "why is he making one equal to two?"
|
# ? Dec 21, 2010 23:35 |
|
Jonnty posted:Also, just don't use "l" as a variable if at all possible. My first thought when reading that was "why is he making one equal to two?" If your font doesn't distinguish 1, l and I, it is broken.
|
# ? Dec 21, 2010 23:47 |
|
rjmccall posted:It's the line with the break statement. First, break; doesn't do what I think you think it does, and second, you have the condition wrong. What condition?
|
# ? Dec 22, 2010 00:04 |
|
Er. The condition on the line with the break statement.
|
# ? Dec 22, 2010 00:10 |
|
Other errors I see: Don't use the word 'size' as a #define macro. At a minimum, uppercase it. `main()' isn't valid as a declaration for your main function; `int main()' is. Don't use magic numbers, like -32766.
|
# ? Dec 22, 2010 01:19 |
|
Alright, thanks, I got it to work now
icantfindaname fucked around with this message at 03:32 on Dec 22, 2010 |
# ? Dec 22, 2010 01:53 |
|
Whoops, actually it compiles but doesn't display thecode:
Any more insight? Here's the program as it is now code:
|
# ? Dec 22, 2010 03:32 |
|
icantfindaname posted:
k != 0 || l != 0 RichardA fucked around with this message at 08:04 on Dec 22, 2010 |
# ? Dec 22, 2010 04:52 |
|
I think I have this figured out. How would I express the condition !(both k and l are equal to zero)? (!(k && l == 0)) doesn't seem to be working
|
# ? Dec 22, 2010 07:43 |
|
icantfindaname posted:I think I have this figured out. How would I express the condition !(both k and l are equal to zero)? (!(k && l == 0)) doesn't seem to be working !((k == 0) && (l == 0))
|
# ? Dec 22, 2010 07:49 |
|
Thanks, it finally works now
|
# ? Dec 22, 2010 08:07 |
|
boak posted:!((k == 0) && (l == 0)) ((k != 0) || (l != 0))
|
# ? Dec 22, 2010 11:17 |
|
mr_jim posted:((k != 0) || (l != 0)) code:
|
# ? Dec 22, 2010 11:29 |
|
mr_jim posted:((k != 0) || (l != 0)) Edit: beaten
|
# ? Dec 22, 2010 11:30 |
|
I know.
|
# ? Dec 22, 2010 11:37 |
|
Standish posted:
code:
|
# ? Dec 22, 2010 18:23 |
|
Brecht posted:`main()' isn't valid as a declaration for your main function; `int main()' is. Maybe he's going retro.
|
# ? Dec 23, 2010 09:13 |
|
I'm having some problems with pointers to pointers. I have a 2d array of chars that I want to pass to this function:code:
code:
quote:warning: passing argument 1 of 'doShit' makes pointer from integer without a cast What am I doing wrong? 1294028 fucked around with this message at 17:19 on Dec 24, 2010 |
# ? Dec 24, 2010 17:13 |
|
You are dereferencing the array.
|
# ? Dec 24, 2010 17:42 |
|
It'll still be wrong after fixing that. A 2D array doesn't properly degrade to a pointer to a pointer: http://codepad.org/dHtivhoW . GCC, in its infinite wisdom, doesn't even warn about this by default. All but the first dimension of a multidimensional array have to be specified in the function signature: http://codepad.org/gVyGz5BY
|
# ? Dec 24, 2010 18:06 |
|
code:
|
# ? Dec 24, 2010 18:09 |
|
Dicky B posted:
This too, does not do what you think. The "a" there is meaningless except that it needlessly makes different values of "a" force new instantiations even though the generated function will be the same (the parameter type will be "char(*)[b]" no matter the [valid] value of "a"). What you probably meant was: code:
You could also always use a custom datastructure such as Boost or tr1 array, or Boost.Multi_Array.
|
# ? Dec 24, 2010 18:42 |
Does anyone know what std::_Tree is? I'm trying to compile the python bindings for Ogre on Linux, and the wrappers make reference to this, causing gcc to bork. From what I can tell it appears to be an MSVC-only helper class of some kind.
|
|
# ? Dec 25, 2010 16:22 |
|
A OBLIVION MOD... posted:Does anyone know what std::_Tree is? I'm trying to compile the python bindings for Ogre on Linux, and the wrappers make reference to this, causing gcc to bork. From what I can tell it appears to be an MSVC-only helper class of some kind. std::_Tree is a utility classed used to implement std::set and std::map. What it likely means is you are using a library that was built against MSVC, and tried to build the new shared library using gcc. That will never work because of the differences in the C++ implementation's between MSVC and gcc. Whichever library brought in std::_Tree needs to be recompiled with gcc compiler (assuming that is your target compiler).
|
# ? Dec 25, 2010 17:22 |
litghost posted:std::_Tree is a utility classed used to implement std::set and std::map. What it likely means is you are using a library that was built against MSVC, and tried to build the new shared library using gcc. That will never work because of the differences in the C++ implementation's between MSVC and gcc. Whichever library brought in std::_Tree needs to be recompiled with gcc compiler (assuming that is your target compiler). If he's actually building on Linux, as I understand, then it won't be a case of libraries built with the wrong compiler (MSVC for Linux? Nah.), but source code depending on implementation details of the Dinkumware STL. Check if there isn't somewhere you can configure something about the compiler or standard library being used, because it sounds like it's some wrong code being pulled in. Also look for std::_Tree in the Ogre source code, and if they actually do use that explicitly anywhere, write an angry mail to the developers telling them to stop relying on implementation details.
|
|
# ? Dec 25, 2010 21:16 |
nielsm posted:Also look for std::_Tree in the Ogre source code, and if they actually do use that explicitly anywhere, write an angry mail to the developers telling them to stop relying on implementation details. This is exactly what's happening, albeit in the PythonOgre source code. They're using std::_Tree in the bindings themselves. I'm not interested in fixing their mistakes, so on to Ogre proper I go.
|
|
# ? Dec 25, 2010 21:42 |
|
I don't know if anyone here is familiar with OpenCV, but I'm doing some basic facial detection then feeding that into facial recognition using the eigenfaces stuff that's built into OpenCV. Seems simple enough, but I'm not getting great results and my eigenfaces look a bit... funny, the box seems to be too wide on the right and bottom edges: Pretty thing, isn't she? In my detection method I'm also resizing the image that's returned, so an issue could be there! I feel like I may be doing something exceptionally dumb, but I spent the entire day rewriting this thing from scratch so I may very well have missed something. http://pastebin.com/PPR6Jk3A is my getFaceFromImage() function code
|
# ? Dec 29, 2010 02:09 |
|
I can't really think of what to call them, but is there a widget used to make terminal-emulator-like windows? Things like xterm, cmd.exe, gVim. What is that specific type of "text-area" called? A character frame buffer? Are there any GUI frameworks that have built-in widgets like that?
|
# ? Dec 29, 2010 06:22 |
|
I think http://library.gnome.org/devel/vte/unstable/
|
# ? Dec 29, 2010 09:38 |
|
Vanadium posted:I think http://library.gnome.org/devel/vte/unstable/ Wow thanks!
|
# ? Dec 29, 2010 09:46 |
|
|
# ? Jun 7, 2024 05:34 |
|
Fixed it! I think. CvRect takes an (x,y) coordinate and a width and a height, not two (x,y) coordinates - oops.
|
# ? Dec 29, 2010 15:17 |