What do you like least about C++?

This is a discussion on What do you like least about C++? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by MarkZWEERS No default types for template arguments Ah, but you can have default types for template arguments ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,428
    Quote Originally Posted by MarkZWEERS View Post
    No default types for template arguments
    Ah, but you can have default types for template arguments (I assume you mean the template types inside the template<> part?). For classes it works, but not for functions (that's a shame).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,168
    mandatory specialisation of all arguments following a one which has been specialised
    What? O_o

    Example?

    Soma

  3. #18
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    but not for functions
    Yeah, that's exactly what I mean....

    Josuttis an Vandevoorde mention in their book "C++ Templates" that very, very probably the next standard will allow default types for template arguments, as well as a 'double' as non-type template argument. They say that there are no technical difficulties in doing so. Can't wait...

  4. #19
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,428
    I agree. C++ is missing that one
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    Example?
    pseudo-code
    Code:
    template<typename T1, typename T2> 
      class TestClass {
        ....
      __  function();
      }
    template<typename T2>  // partial specialisation for first template argument, #error!
    __ class<char, T2> :: function()
    What if I've designed my template class, later I decide to add a function 'function' with only its first argument specialised? As far as I know, after a partial specialisation everything has to be specialised.

    Henceforth, this will work:

    Code:
    template<typename T1>  // partial specialisation for second template argument, OK
    __ class<T1, char> :: function()
    EDIT: This is especially horrible with traits... along the road you discover over and over again the "correct" order of the arguments
    Last edited by MarkZWEERS; 06-10-2008 at 02:22 PM. Reason: added comments in code

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21