Joshua Burkholder

Back to Profile: Burkholder

Comments

  • CES 2011: Kinect and Live Mesh

    If I'm logged into my Kinect-enabled XBox 360, I can initiate a video call with someone using Windows Live Messenger 2011 on a PC ... and they can accept that video call.  However, ...

    ... How does someone using Windows Live Messenger 2011 on a PC initiate a video call with me that I can actually accept when I'm logged into my Kinect-enabled XBox 360?  When I try this scenario, I see a prompt at the bottom of my XBox 360 screen that someone wants to video chat, but I don't see a way to switch over to Video Kinect and accept the video call.  What am I missing?

    Thanks In Advance For Any Help,
    Joshua Burkholder

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 10 of 10

    @Philhippus:Yes, Stephan has only scratched the surface of template metaprogramming (i.e. using C++ templates to create/modify C++ code at compile-time).  Here are a few good references that go into greater detail:

    These books are outstanding ... esp. C++ Templates - The Complete Guide.  Alexandrescu's book is about more than just template metaprogramming ... however, it applies template metaprogramming throughout the text and is an excellent book for showing what can be done with template metaprogramming.  Ensure that you look at the correction to Typelists (i.e. use templates, not #defines, to create lists of types) that Alexandrescu made here: http://www.drdobbs.com/cpp/184403813

    NOTE:  There is also a horribly written book called "C++ Template Metaprogramming - Concepts, Tools, and Techniques from Boost and Beyond".  If you can get through this book ... with its coverage of template metaprogramming for seemingly template metaprogramming's sake and its occasional lack of structure & direction, then you will pick up some template metaprogramming techniques ... and (most importantly) be introduced to the template metaprogramming library called MPL from boost.org:  http://www.boost.org/doc/libs/1_45_0/libs/mpl/doc/index.html  . However, the documentation for Boost's MPL is about as good as the book, so I would go to the documentation first ( http://www.boost.org/doc/libs/1_45_0/libs/mpl/doc/tutorial/tutorial_toc.html  ) ... and then take a look at that book at a library or a bookstore (rather than wasting your money on it ... like I did).

    Hope This Helps,
    Joshua Burkholder

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 10 of 10

    @Gordon: MinGW (Minimalist GNU for Windows) can provide gcc and g++ for use off of a portable device (i.e. usb thumb-drive).  Additionally, MinGW ... and MSYS (the MinGW Shell) ... can be "installed" with non-admin rights ... the MinGW installer just needs a folder with no spaces in its path to which it will download all the relevent files and subfolders.

    Previous MinGW installers were worthless; however, the current MinGW installer is outstanding (in comparison).  MinGW can be downloaded here:  http://sourceforge.net/projects/mingw/

    At the time that I'm writing this, "mingw-get-inst-20101030.exe" is the current installer and that installer downloads and installs gcc and g++ version 4.5.0.  The installer can also be used to install MSYS, so ensure that you also install the MSYS Basic System ... this will give you a shell that includes make for makefiles and a number of other utilities.

    Here are step-by-step screen captures of what you should see during the install process:  http://www.joshuaburkholder.com/glut/step_1/

    After the install is complete, just copy and paste the MinGW folder to your portable device ... and ensure that there are no spaces in MinGW's new path.  For ease of access to MSYS ... and therefore to the versions of gcc and g++ in MinGW, create a link to "C:\MinGW\msys\1.0\msys.bat" (or the msys.bat file wherever you installed MinGW) and change the link's "Start in:" path to "C:\MinGW\msys\1.0\bin" (or similar).

    Hope This Helps,
    Joshua Burkholder

    NOTE:  By default, executables built with MinGW's g++ dynamically link to the following DLLs: "C:\MinGW\bin\libgcc_s_dw2-1.dll" and "C:\MinGW\bin\libstdc++-6.dll" ... hence, you should use the

    -enable-auto-import
    flag with g++ when building executables in this default setting.  The current installer does not pollute your PATH environment variable, so you may want to add C:\MinGW\bin (or similar) to your System or User PATH environment variable so that your g++ produced EXEs can find those DLLs ... esp. if you are going to launch those EXEs by double-clicking on them.  MSYS temporarily prepends C:\MinGW\msys\1.0\local\bin (if it exists), C:\MinGW\bin, and C:\MinGW\msys\1.0\bin to the PATH environment variable ... so if you run your EXEs from MSYS, your executables will find the needed DLLs.  Or, you can make copies of these two DLLs and place them next to your EXE.  Alternatively, you can just statically link those libraries to your EXE by using the
    -static
    flag with g++ ... which adds about 1 MB to your executable ... and allows double-click execution of your EXE without having to pollute your PATH environment variable or without having to place DLLs next to your EXE.

    NOTE:  To change the /mingw alias from C:\MinGW to whatever the portable device path is, edit C:\MinGW\msys\1.0\etc\fstab.

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 9 of n

    @STL:Thanks for the heads up on not taking the address of Standard Library member functions.  Where is that detailed in the standard?

    Thanks In Advance,
    Joshua Burkholder

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 9 of n

    @NotFredSafe:

    This is __not__ a compiler bug in either GNU/g++ or Visual Studio.

    Your code assumes that type U directly has member functions begin() const and end() const, vice inheriting them.  Your code also assumes that const_iterator comes directly from U, vice inheriting it.  The C++ standard does __not__ assume this for associative containers like std::map and std::set (see section 23.6.1 point 2 [for std::map] and section 23.6.3 point 2 [for std::set] of the current draft of the C++ standard).  According to the C++ standard, implementers are free to typedef std::map<...>::const_iterator or std::set<...>::const_iterator any way they want to ... so since Dinkumware uses inheritance to implement std::map and std::set, then Dinkumware can choose to just use the inherited std::_Tree<...>::const_iterator std::_Tree<...>::begin() const and std::_Tree<...>::const_iterator std::_Tree<...>::end () const.  Visual Sudio uses Dinkumware's STL implementation ... while GNU/g++ does not.  Dinkumware's std::map and std::set implementation uses inheritance ... while GNU/g++ does not.  If GNU/g++ used this inherited structure, then the results from GNU/g++ and Visual Studio would be the same.  Here's an example:

    #include <iostream>
    #include <vector>
    #include <list>
    #include <set>
    #include <map>
    
    template <typename T>
    struct is_container {
        template <
            typename U,
            typename U::const_iterator (U::*)() const,
            typename U::const_iterator (U::*)() const
        >
        struct sfinae {};
        
        template < typename U >
        static char test ( sfinae< U, &U::begin, &U::end >* );
    
        template < typename U >
        static long test ( ... );
        
        enum {
            value = ( sizeof( test< T >( 0 ) ) == 1 )
        };
    };
    
    template < typename T >
    struct ContainerInheritedFrom {
        typedef T const * const_iterator;
        const_iterator begin() const {
            return const_iterator();
        }
        const_iterator end() const {
            return const_iterator();
        }
    };
    
    template < typename T >
    struct ContainerThatInherits : public ContainerInheritedFrom< T > {
        //
    };
    
    int main () {
        std::cout << is_container<std::vector<std::string> >::value << ' ';
        std::cout << is_container<std::list<std::string> >::value << ' ';
        std::cout << is_container<std::set<std::string> >::value << ' ';
        std::cout << is_container<std::map<std::string, std::string> >::value << '\n';
    
        
        ContainerInheritedFrom< std::string > cif;
        ContainerInheritedFrom< std::string >::const_iterator cif_ci = cif.begin();
        cif_ci = cif.end();
    
        ContainerThatInherits< std::string > cti;
        ContainerThatInherits< std::string >::const_iterator cti_ci = cti.begin();
        cti_ci = cti.end();
    
        std::cout << is_container< ContainerInheritedFrom< std::string > >::value << ' ';
        std::cout << is_container< ContainerThatInherits< std::string > >::value << '\n';
    } 
    
    GNU/g++ Version 4.5.0:
    g++ main.cpp -W -Wall -o main.exe
    ./main.exe
    1 1 1 1
    1 0
    Visual Studio 2010:
    1 1 0 0
    1 0

    Because your code requires something that the C++ standard does not require, your code is not a good way to check for a container at compile time ... and is implementation dependent.  You should change your code to reflect the C++ standard requirements.

    Also, good info on Substitution Failure Is Not An Error (SFINAE) can be found on page 106 of C++ Templates: The Complete Guide by Vandevoorde and Josuttis.

    Hope This Clarifies,
    Joshua Burkholder

     P.S. - If you wanted to keep your previous structure and still be able to pick up the associative containers, std::set and std::map, then you could always use a partial specialization on your is_container<...> struct.  Here's an example:

    #include <iostream>
    #include <vector>
    #include <list>
    #include <set>
    #include <map>
    
    template < typename T1, typename T2 >
    struct is_same {
        static bool const value = false;
    };
    
    template < typename T1 >
    struct is_same < T1, T1 > {
        static bool const value = true;
    };
    
    template <typename T>
    struct is_container {
    
        template <
            typename U,
            typename U::const_iterator (U::*)() const,
            typename U::const_iterator (U::*)() const
        >
        struct sfinae {};
        
        template < typename U >
        static char test ( sfinae< U, &U::begin, &U::end >* );
        
        template < typename U >
        static long test ( ... );
        
        static bool const value = ( sizeof( test< T >( 0 ) ) == 1 );
    };
    
    template <
        template < typename, typename, typename > class S, /* Set */
        typename K, /* Key */
        typename C, /* Compare */
        typename A  /* Allocator */
    >
    struct is_container < S< K, C, A > > {
        static bool const value = (
            is_same< S< K, C, A >, std::set< K, C, A > >::value
            ||
            is_same< S< K, C, A >, std::multiset< K, C, A > >::value
        );
    };
    
    template <
        template < typename, typename, typename, typename > class M, /* Map */
        typename K, /* Key */
        typename T, /* T */
        typename C, /* Compare */
        typename A  /* Allocator */
    >
    struct is_container < M< K, T, C, A > > {
        static bool const value = (
            is_same< M< K, T, C, A >, std::map< K, T, C, A > >::value
            ||
            is_same< M< K, T, C, A >, std::multimap< K, T, C, A > >::value
        );
    };
    
    template < typename T >
    struct ContainerInheritedFrom {
        typedef T const * const_iterator;
        const_iterator begin() const {
            return const_iterator();
        }
        const_iterator end() const {
            return const_iterator();
        }
        
    };
    
    template < typename T >
    struct ContainerThatInherits : public ContainerInheritedFrom< T > {
        //
    };
    
    int main () {
        std::cout << is_container<std::vector<std::string> >::value << ' ';
        std::cout << is_container<std::list<std::string> >::value << ' ';
        std::cout << is_container<std::set<std::string> >::value << ' ';
        std::cout << is_container<std::map<std::string, std::string> >::value << '\n';
    
        
        ContainerInheritedFrom< std::string > cif;
        ContainerInheritedFrom< std::string >::const_iterator cif_ci = cif.begin();
        cif_ci = cif.end();
    
        ContainerThatInherits< std::string > cti;
        ContainerThatInherits< std::string >::const_iterator cti_ci = cti.begin();
        cti_ci = cti.end();
    
        std::cout << is_container< ContainerInheritedFrom< std::string > >::value << ' ';
        std::cout << is_container< ContainerThatInherits< std::string > >::value << '\n';
        
    } 
    
    Of course, this is a kludge (so you don't have to dramatically modify your code) and is not recommended ... but it works. Wink

    Based on the kludge above, GNU/g++ Version 4.5.0 outputs:

    g++ main.cpp -W -Wall -o main.exe
    ./main.exe
    1 1 1 1
    1 0
    Based on the kludge above, Visual Studio 2010 outputs:
    1 1 1 1
    1 0

     

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 9 of n

    @Burkholder:Disregard my no-compiler-warning for C++ in Visual Studio 2010.  I was compiling with Warning Level Level3, vice Warning Level Level4.  Once I switched to Level4, I received the following warning

    warning C4238: nonstandard extension used : class rvalue used as lvalue
    Still no compiler error though, but at least this is the same behavior as g++.

     

    Joshua Burkholder

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 9 of n

    @STL:  Your description of not being able to use & on the temporary created by std::string concatenation doesn't hold for C++ in Visual Studio 2010.  For instance, when I compile the following code ...

    #include <iostream>
    using std::cout;
    using std::endl;
    
    #include <string>
    using std::string;
    
    int main () {
        string x( "hello " );
        string y( "world" );
        cout << ( x + y ) << endl;
        cout << &( x + y ) << endl;
        return 0;
    }
    
    ... there are no compiler warnings and no compiler errors.  When I run that compiled code, I get the following output:
    hello world
    002FFD54
    Aside:  Using g++ 4.5.0 with -std=c++0x, there is a compiler warning, but no compiler errors.  Here is the compiler warning:
    warning: taking address of temporary

     

    If I change std::string to int, then everything works as expected and I get the following compilation error for C++ in Visual Studio 2010:

    error C2102: '&' requires l-value
    .  In g++ 4.5.0, I get the following compilation error:
    error: lvalue required as unary '&' operand

     

    Joshua Burkholder

  • C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 9 of n

    > anyway, what will the next video be about?

    I'm open to suggestions. I'd like to cover simple techniques before advanced ones (looking at the STL's implementation would be advanced). I think I might demonstrate <type_traits>. (Note that I won't be covering iostreams in this series.)

     

    #include <type_traits>, decltype, and the rest of the template metaprogramming (aka using C++ to "preprocess"/modify/script C++ during compile-time) material would be interesting.  Any info on how to use std::string or char * ... or whatever ... for manipulating strings at compile-time in C++0x would be appreciated.  If the new standard still does not support manipulating strings at compile-time without work-arounds (aka boost::mpl::string), then what is the current justification that the standards committee gives for still not allowing string manipulations at compile-time?  For template-metaprogramming, I'd personnally like to see an example of loop-unrolling ... right now, if I need a for ( i = 0; i < n; ++i ) { v[i]=...; } but I just want a v[0]=...; v[1]=...; ...; v[n]=...;, then I just script that unrolled-loop to a text file and copy & paste ... which works ... but is a kludge.  I'd like C++ to do that loop-unrolling for me at compile-time ... so I can share and reuse that C++ solution.

     

    Also, generating random floats or doubles from a Normal distribution using #include <random> would be great ... esp. for simultations, stocastic models, and games.  Any explanation on how to create our own distributions would also be great.

     

    Discussing the usefulness, pros and cons, of std::valarray and std::slice from #include <valarray> ... and showing off some of the MATLAB-like functionality of std::valarray (like valarray1 + valarray2, pow( valarray1, 2. ), valarray1.sum(), valarray1.apply( user_function ), etc.)

     

    Finally, simultaneously returning multiple values from a function or method using #include <tuple> and then accessing those values ... esp. best practices. 

     

    Thanks In Advance,

    Joshua Burkholder

     

  • Silverlight TV Episode 1: The Joys of Trusted ​Out-of-​Browser Applications

    I love the format of the show.  It's short, sweet, and the mistakes are still in there ... so it's not just an info-mmercial.

     

    I want to see the test cases/experiments of the Silverlight team trying to incorporate XNA (the 3D parts) or WPF 3D into Silverlight.

     

    Thanks In Advance.

     

     

  • This Week on C9: Project Natal, Qex for SQL, and Bing for Devs

    In the "Adam Kinney - Motion Capture viewer in Silverlight" section of the "This Week on Channel 9" video, it was mentioned that Nikola used the new 3D features of Silverlight 3.0 to create his Motion Capture Viewer.  That is not the case.  Nikola's Motion Capture Viewer only requires Silverlight 2.0.  Nikola coded the point, vector, matrix, quaternion, etc. classes needed for the quick software rendering of those stick figures (all of which is provided in his Silverlight 2.0 source code) ... and all easily handled by the Silverlight 2.0 player.

    Very Respectfully,
    Joshua Burkholder