Templates ........

This is a discussion on Templates ........ within the C++ Programming forums, part of the General Programming Boards category; I want to know about the templates. In books I have found that they are not portable. So, how to ...

  1. #1
    Registered User Moni's Avatar
    Join Date
    Oct 2002
    Location
    Dhaka, Bangladesh.
    Posts
    104

    Templates ........

    I want to know about the templates. In books I have found that they are not portable. So, how to make it portable?
    We all are the components of a huge program...... the programmer is always debugging us with His debugger.

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Maybe that book is really old? Templates are part of the C++ standard.

    How do I use X questions are really too general. Searching google typically works nicely.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Actually, many compilers choke on templates, depending on the limits that are push, and in fact, MS compilers are usually the least supportive of advanced templates. If you keep it simple, you should be fine, though. Compilers usually implement a template compiler that runs beforehand, and it sometimes just resorts to a form of macro expansion for the templates, generating all possible copies textually, and to greater and lesser degrees of efficiency/redundancy.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Templates from DLL or static library problem
    By mikahell in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2008, 12:49 AM
  2. Questions about Templates
    By Shamino in forum C++ Programming
    Replies: 4
    Last Post: 12-17-2005, 11:22 PM
  3. templates and inheritance problem
    By kuhnmi in forum C++ Programming
    Replies: 4
    Last Post: 06-14-2004, 02:46 AM
  4. When and when not to use templates
    By *ClownPimp* in forum C++ Programming
    Replies: 7
    Last Post: 07-20-2003, 09:36 AM

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