Thread: recursive dereferencing template revisited

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Post recursive dereferencing template revisited

    ok, so my last posting on the subject wasn't exactly correct (big suprise). what I'd really like to know is if the solution is complete. I figured that if anyone could break my code it'd be you guys. =)

    the purpose of the library is of course to provide a compile-time dereferencing mechanism for pointers and specialized types. for example:

    Code:
    #include <iostream>
    #include "content.h"
    
    using namespace std;
    using namespace xtd;
    
    int
    main( void )
    {
    	int
    	   i = 1024,
    	   * p = &i,
    	   ** pp = &p,
    	   *** ppp = &pp;
    	extract( ppp )++;
    	cout << extract( ppp ) << endl;
    	return 0;
    }
    below I've attached the header file and some minor examples. any comments or suggestions are welcome.
    Last edited by Sebastiani; 02-16-2008 at 12:11 PM. Reason: clarity
    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;
    }

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I've made some minor changes: the header file was renamed to 'extract.h' (the actual file extension was .hpp but the board doesn't allow attachments with that extension). I also removed the ugly specialization macro and added comments for clarity.

    I've done a lot of testing but then again there's always the chance that I may have overlooked something. please let me know if you have any problems compiling the code...
    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. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM