Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

enable_if lambda capture

jimdempseyatthecove
Honored Contributor III
658 Views

I am using V16.0 update 2, and for the moment wish to stick with C++11 (Will look at C++14 in V17 later)

I have a template library that used to work well in the earlier versions of the compiler (C++03), and I am revising them to make use of the C++11 features (in particular variadic templates and use of tuples).

I've got most of the issues worked out except for my templates that manipulate lambda capture objects. Perhaps C++11 "fixed" something (got more strict) with lambda captures. As potential means to work around the issues, I'd like to know if there is a way to determine if a template type is a lambda capture object, and use an enable_if to enable or disable the expansion. something along the line of

  is_lambda_capture< T >::value

to return true or false

Jim Dempsey

0 Kudos
3 Replies
Kittur_G_Intel
Employee
658 Views

Hi Jim,
Good question, need to look into and get back to you on this, thanks
Regards,
Kittur 

0 Kudos
jimdempseyatthecove
Honored Contributor III
658 Views

I think these will work (haven't tried)

template<typename fnT, typename... ArgsT>
typename std::enable_if<std::is_function<decltype(fn)>::value && !std::is_object<decltype(fn)>::value>::type
my_template_name(
  fnT fn,
  ArgsT args
  )
{
 ...
}

template<typename lambdaT, typename... ArgsT>
typename std::enable_if<std::is_function<decltype(fn)>::value && std::is_object<decltype(fn)>::value>::type
my_template_name(
  lambdaT fn,
  ArgsT args
  )
{
 ...
}

Jim Dempsey

0 Kudos
Kittur_G_Intel
Employee
658 Views

Jim, yes that should work and I am also awaiting a response from the FE team as well and will keep you updated accordingly.

Kittur

0 Kudos
Reply