CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: jwbarton

Page 1 of 10 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    10
    Views
    979

    Re: boost::shared_ptr with std::vector

    Looking at your first post, I can see a problem with your use of shared_ptr.

    A shared_ptr will delete the object once the last shared_ptr that points to an object goes out of scope. Since you are...
  2. Replies
    4
    Views
    541

    Re: valarray and math.h

    Check if you are including math.h inside of stdafx.h.

    If you are, you need to put the #define inside of stdafx.h, before including math.h. Otherwise any include of math.h after stdafx.h is...
  3. Replies
    14
    Views
    10,637

    Re: How to use #define _CRT_SECURE_NO_DEPRECATE?

    Yes, this is one of the correct ways to handle this.

    When using precompiled headers with the Microsoft compiler, it ignores any code in the source file until it finds the include of the...
  4. Replies
    64
    Views
    6,677

    Re: CArray vs. std::vector

    Using std::string instead of CString with the VS2010 compiler can produce faster results without needing to rely on tricks (treating the CString as a POD).

    The std::string object in VS2010...
  5. Replies
    64
    Views
    6,677

    Re: CArray vs. std::vector

    This has been fixed in Visual Studio 2010 - the default for debug mode is still to have checked iterators, but release mode has _SECURE_SCL set to 0 (at least by default).

    Best regards,
    John
  6. Replies
    22
    Views
    2,076

    Re: Changing function based on a condition?

    I think to get the same meaning as the original, better style would be


    bool valid = false;
    while (! valid)


    (and then set valid = true in when the string entered is valid).

    Best...
  7. Replies
    34
    Views
    4,642

    Re: Detecting memory leaks (VC8)

    This most likely isn't reporting a leak due to the small string optimization that is done with std::string.

    Basically, for strings with 15 characters or less, the data for the string is held...
  8. Replies
    6
    Views
    396

    Re: Multiple virtuality

    You can achieve this by using a double dispatch, which is often achieved using the Visitor pattern.

    One way of implementing this is as follows:



    #include <iostream>

    using namespace std;
  9. Replies
    12
    Views
    1,117

    Re: I need help with STL: vector

    I too wouldn't recommend using this, but anyone using STL should still be aware of how it works.

    There are guarantees provided by the standard for each container which specify exactly how and when...
  10. Replies
    12
    Views
    1,117

    Re: I need help with STL: vector

    An erase() on a vector will only invalidate elements after the erase location - iterators to elements before the erase location remain valid.

    An insert() on a vector will only invalidate elements...
  11. Re: print out command that entered

    This isn't necessarily true. When running on Windows, the command line is parsed by the startup code of the executable. This is parsed into the familiar argc/argv before the runtime calls main().
    ...
  12. Replies
    11
    Views
    1,007

    Re: Remove Vector Element

    The behavior you observed is normal.

    When you use remove_if(), the vector is modified by shifting any elements which don't match the predicate up (any which SomeFunc() returns false). The...
  13. Re: Problems designing my vectorized math library

    While conceptually this is true, in practice it depends on the compiler implementation. It is true that the computed result of using a non-member operator with __m128 is the same as making a class...
  14. Re: Problems designing my vectorized math library

    I am not the original poster. I was just curious what the reasons were for the performance problems reported by the original poster.

    My idea was to try to provide the original poster with the...
  15. Re: Problems designing my vectorized math library

    I stand corrected.

    I had the syntax wrong and the compiler error I got didn't help.

    Is this correct?



    __m128& operator+=(__m128& a, __m128 b)
    {
  16. Re: Problems designing my vectorized math library

    I took a quick look at the code generation for an intrinsic __m128 using direct calls to _mm_add_ps() to add the 4 floats, and then the member routine in your float4 class which also calls...
  17. Replies
    7
    Views
    603

    Re: Member function as function argument

    Hi Johnny,

    When I provided the original solution, I was just going for a quick and dirty solution.

    There is a solution which doesn't require writing the BoundModelFunc adaptor (assuming that it...
  18. Replies
    7
    Views
    603

    Re: Member function as function argument

    The easiest way is to just make a new member function of the Model:



    // needed include file:
    #include <cmath> // or <math.h>
  19. Replies
    7
    Views
    603

    Re: Member function as function argument

    Your problem is that you can't pass a pointer to a member function to a routine that expects a pointer to a normal function.

    You need to provide an adaptor that will make bind the model object...
  20. Replies
    17
    Views
    1,953

    Re: First foray into libboost

    I have used boost a bit, but I avoided any part which required a separate library (such as the regex support).

    If the compiler you are using has a tr1 implementation, you may want to use the...
  21. Replies
    4
    Views
    591

    Re: member binary predicate problems!

    You probably don't want to make the functor a static variable. It would then only be initialized the first time that Map::GetSeed is called. This would be bad if you have more than one Map object....
  22. Replies
    8
    Views
    1,349

    Re: Initializing a double to INT_MAX + 1

    How about using the compiler constants:



    #include <climits>

    void test()
    {
    double value = static_cast<double>(INT_MAX) + 1;
    }
  23. Re: Inaccuracy of QueryPerformanceCounter in quickly executing snippets

    You should take a look at the generated assembler code by the compiler.

    When I built your code using Visual Studio 2008 (in release mode), it completely optimized away your loops. Since the...
  24. Re: Output stream Operator Overloading for Enum not working in ostream_iterator

    I built your code with VS2008, and the output when running is:

    Operator Overloading -> A
    Enum Operator Overlaoding -> no
  25. Replies
    5
    Views
    1,963

    Re: using handles to get RichEdit text

    You may want to change the method that you are using to declare your txt variable. You are mixing the TCHAR support (a Microsoft invention which allows building applications which support multiple...
Results 1 to 25 of 249
Page 1 of 10 1 2 3 4



HTML5 Development Center

Click Here to Expand Forum to Full Width