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

Search:

Type: Posts; User: JohnW@Wessex

Page 1 of 80 1 2 3 4

Search: Search took 0.15 seconds; generated 29 minute(s) ago.

  1. Replies
    7
    Views
    1,492

    Template specialisation error

    Does anyone know if there's a way to make this specialisation work?
    I have a feeling that it is not possible to do what I want. Can anyone prove me wrong?

    The previous incarnation of the original...
  2. Re: does a function know how much memory its parameters occupy?

    If you are using a fixed length C array it can also be implemented in this way.
    Where 'N' is the size of the array.
    Be aware of course that each unique combination of T & N will create a another...
  3. Replies
    27
    Views
    6,575

    Re: Bool type problem

    I've worked on a DSP platform where there was no such thing as an 8 bit type.
  4. Re: Overloading std::distance for a specific iterator type

    Thanks, that makes sense.
  5. Overloading std::distance for a specific iterator type

    I have a templated container that defines a forward iterator.

    Calling std::distance on these iterators will generate code that will count the number of iterations it takes to get from the first...
  6. Replies
    27
    Views
    6,575

    Re: Bool type problem

    The result is also highly variable on the types used.
    (Visual Studio 2013)


    struct preferences {
    bool likesMusic : 1;
    bool hasHair : 1;
    bool hasInternet : 1;
    bool hasDinosaur : 1;
    unsigned...
  7. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    :thumb:
  8. Replies
    11
    Views
    4,098

    Re: Templated upcast function

    class Base {};
    class NotBase {};
    class Derived1 : public Base {};
    class Derived2 : public Base {};


    Variant<Derived1, Derived2> values;


    Base& base = values; // Compile fail. Ambiguous...
  9. Replies
    11
    Views
    4,098

    Re: Templated upcast function

    But that generates a runtime error.
    With the Variant template class it's a compile time error.
  10. Replies
    11
    Views
    4,098

    Re: Templated upcast function

    The type checks are now all compile time. It was a fairly simple exercise in the end. :)



    Where are the downcasts? The only casts available to the user are upcasts and they are now all checked...
  11. Replies
    11
    Views
    4,098

    Re: Templated upcast function

    The class it's used in has a variable number of template types. The unused template types default to 'null type' place holders.
    If the check was at compile time then the placeholders fail the test....
  12. Replies
    11
    Views
    4,098

    Re: Templated upcast function

    Do'h!!
    I must have been a bit overtired when I wrote that bit :blush:
  13. Replies
    11
    Views
    4,098

    Re: Templated upcast function

    I think I'm close to a solution, but for a (for the moment) puzzling compiler error.


    template <typename TBase, typename T, const bool IsBase>
    struct DoIt;

    template <typename TBase,...
  14. Replies
    11
    Views
    4,098

    Templated upcast function

    I have a templated function that attempts to upcast a type to a specified base class.
    If TBase is a base of T then a simple upcast is performed.
    If TBase is not a base of T then an exception is...
  15. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    Part of the my personal design brief for my Variant class was to reduce any type safety issues to an absolute minimum. In this I think I've been pretty much successful. The main way to get around...
  16. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    That's an interesting idea, though I still have the niggling doubt in the back of my mind that there may be the possibility of getting more than one instance of Id() for a particular type. I could be...
  17. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    That's actually very similar to what I already had, except that instead of a union I have a data area sized to the largest type (and aligned to a 32bit boundary)
    When a value is stored it uses a...
  18. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    @superbonzo

    I had a chance to look at your suggestions this morning, and, like a lot of good ideas, its seems obvious once you know the solution.

    With a couple of minor changes it grafted in...
  19. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    I've only had a chance to briefly skim your code so I probably misunderstood your method :blush:
  20. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    I've just realised the small, but significant difficulty with that method.

    Any<int, double> any1 = 1;
    Any<double, int> any2 = 1;

    bool b = any1.IsSameTypeAs(any2); // This will return 'false'...
  21. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    Thanks for that.:thumb:
    I'll give it a look over this evening to see if it can be grafted into what I already have.
  22. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    Your example isn't solving the same problem as what I was describing.

    What I my class is designed to do is this.
    (Types in the template parameter list must be unique; no duplicates)



    int...
  23. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    Actually the implementation has a lot of type safety. That was one of the goals I had in mind.

    I have static asserts that will ensure a compile error if an unsupported type is requested.

    int i;...
  24. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    Possibly. It's not clear what is going on behind the scenes. If it's just using the hash_code and the generation of the type_info is at compilation time then that would have been a perfect...
  25. Replies
    48
    Views
    12,146

    Re: Is this guaranteed to be correct?

    That's fine.



    This is for an ARM based board with no OS, single threaded with a few interrupts, and a message passing cooperative scheduler.



    I couldn't find a way to use RTTI that didn't...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4





Click Here to Expand Forum to Full Width

Featured