paulftw/hiberlite

typeof portability

d-led opened this issue · 2 comments

in hiberdefs.h, the HIBERLITE_NVP macro contains typeof(Field). In c++11 mode you could use decltype.

maybe something like that:

#if (defined _MSC_VER && _MSC_VER< 1600)
#include <boost/typeof/typeof.hpp>
#define HIBERLITE_NVP(Field) hiberlite::sql_nvp< BOOST_TYPEOF(Field) >(#Field,Field)
#else
#define HIBERLITE_NVP(Field) hiberlite::sql_nvp< decltype(Field) >(#Field,Field)
#endif

Looks like a good idea. Feel free to send a pull request.

Is there maybe a way to use boost in both cases? I'd expect them to offer a library of common macros like that.

The boost solution works in the new compilers by itself as well, since that macro is doing exactly that implementation choice based on the detected compiler, but since the rest of your library doesn't need boost, I'd keep an option of not using boost. Some libraries perform the configuration in a special header. i.e. wallaroo. I'll try to make a pull request when time's available.