[type_traits] extension has_operator_xxx - conforming to coding guidelines for ICE

I have tried to comply with the coding guidelines for integral constant expressions (http://www.boost.org/development/int_const_guidelines.html). I have been able to comply with most of them but still have the following issue:
Don't use dependent default parameters for non-type template parameters. For example:
template <class T, int I = ::boost::is_integral<T>::value> // Error can't deduce value of I in some cases. struct foobar;
Rationale: this kind of usage fails for Borland C++. Note that this is only an issue where the default value is dependent upon a previous template parameter, for example the following is fine:
Is there any known workaround for this? In my case, int is replaced by bool but I think it is the same issue. Frédéric

On 2/3/2011 2:36 PM, Frédéric Bron wrote:
I have tried to comply with the coding guidelines for integral constant expressions (http://www.boost.org/development/int_const_guidelines.html). I have been able to comply with most of them but still have the following issue:
Don't use dependent default parameters for non-type template parameters. For example:
template<class T, int I = ::boost::is_integral<T>::value> // Error can't deduce value of I in some cases. struct foobar;
Rationale: this kind of usage fails for Borland C++. Note that this is only an issue where the default value is dependent upon a previous template parameter, for example the following is fine:
Is there any known workaround for this? In my case, int is replaced by bool but I think it is the same issue.
I don't know if the following is an improvement, but... template< class T, class I = boost::integral_constant< int, boost::is_integral<T>::value >
struct foobar; template< class T > struct foobar< T, boost::integral_constant< int, 0 > > { ... }; (Alternatively, use boost::mpl::int_ (and its ilk).) - Jeff

Frédéric Bron wrote:
Don't use dependent default parameters for non-type template parameters. For example:
template <class T, int I = ::boost::is_integral<T>::value> // Error can't deduce value of I in some cases. struct foobar;
Rationale: this kind of usage fails for Borland C++. Note that this is only an issue where the default value is dependent upon a previous template parameter, for example the following is fine:
Is there any known workaround for this? In my case, int is replaced by bool but I think it is the same issue.
Hi, you could try to add an indirection. template <class T, bool B> struct foobar_aux; template <class T> struct foobar : foobar_aux<T, ::boost::is_integral<T>::value> {}; HTH, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/type-traits-extension-has-operator-xxx-co... Sent from the Boost - Dev mailing list archive at Nabble.com.

AMDG On 2/3/2011 2:36 PM, Frédéric Bron wrote:
I have tried to comply with the coding guidelines for integral constant expressions (http://www.boost.org/development/int_const_guidelines.html). I have been able to comply with most of them but still have the following issue:
Don't use dependent default parameters for non-type template parameters. For example:
template<class T, int I = ::boost::is_integral<T>::value> // Error can't deduce value of I in some cases. struct foobar;
Rationale: this kind of usage fails for Borland C++. Note that this is only an issue where the default value is dependent upon a previous template parameter, for example the following is fine:
Is there any known workaround for this? In my case, int is replaced by bool but I think it is the same issue.
I personally ignore this page. It was originally written for VC 6 and Borland 5.5 which are both pretty much irrelevant at this point. Unless someone can confirm that these problems still exist in recent versions of Codegear, I vote that we remove this page. In Christ, Steven Watanabe

On 02/03/2011 05:13 PM, Steven Watanabe wrote:
AMDG
On 2/3/2011 2:36 PM, Frédéric Bron wrote:
I have tried to comply with the coding guidelines for integral constant expressions (http://www.boost.org/development/int_const_guidelines.html). I have been able to comply with most of them but still have the following issue:
Don't use dependent default parameters for non-type template parameters. For example:
template<class T, int I = ::boost::is_integral<T>::value> // Error can't deduce value of I in some cases. struct foobar;
Rationale: this kind of usage fails for Borland C++. Note that this is only an issue where the default value is dependent upon a previous template parameter, for example the following is fine:
Is there any known workaround for this? In my case, int is replaced by bool but I think it is the same issue.
I personally ignore this page. It was originally written for VC 6 and Borland 5.5 which are both pretty much irrelevant at this point. Unless someone can confirm that these problems still exist in recent versions of Codegear, I vote that we remove this page.
In Christ, Steven Watanabe
I remember that xlC 10.1 had also similar problems in the past.

On 3 February 2011 23:13, Steven Watanabe <watanabesj@gmail.com> wrote:
I personally ignore this page. It was originally written for VC 6 and Borland 5.5 which are both pretty much irrelevant at this point. Unless someone can confirm that these problems still exist in recent versions of Codegear, I vote that we remove this page.
I don't like removing content that may be of use to someone. I still get the occasional ticket for Borland 5.5, and put a little effort into supporting it. We could make it less accessible though (maybe create a page for obsolete compilers and link from there), and put a disclaimer at the top of the page. Daniel

On Fri, Feb 4, 2011 at 4:36 AM, Daniel James <dnljms@gmail.com> wrote:
On 3 February 2011 23:13, Steven Watanabe <watanabesj@gmail.com> wrote:
I personally ignore this page. It was originally written for VC 6 and Borland 5.5 which are both pretty much irrelevant at this point. Unless someone can confirm that these problems still exist in recent versions of Codegear, I vote that we remove this page.
I don't like removing content that may be of use to someone. I still get the occasional ticket for Borland 5.5, and put a little effort into supporting it. We could make it less accessible though (maybe create a page for obsolete compilers and link from there), and put a disclaimer at the top of the page.
A disclaimer at the least. --Beman

I have tried to comply with the coding guidelines for integral constant expressions (http://www.boost.org/development/int_const_guidelines.html).
I personally ignore this page. It was originally written for VC 6 and Borland 5.5 which are both pretty much irrelevant at this point. Unless someone can confirm that these problems still exist in recent versions of Codegear, I vote that we remove this page.
I now comply with all the rules. It seems that VC++ has still some issues with having logical operators in default values of bool template parameters. VC++ yields compile time error with: template < T, bool B= expr1 and expr2 > struct foo; When replacing 'and' by '&&' the error disappears. When replacing 'expr1 and exp2' by 'ice_and<expr1, expr2>::value' it also works and removes some warnings in g++. So it seems that this coding requirements are still useful. New version of the type_traits extension available here: - vault unix: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=type_traits.tar.bz2&directory=Extension& - vault dos: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=type_traits-dos.tar.bz2&directory=Extension& - sandbox: http://svn.boost.org/svn/boost/sandbox/type_traits/ Frédéric

Frédéric Bron wrote:
New version of the type_traits extension available here: - vault unix: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=type_traits.tar.bz2&directory=Extension& - vault dos: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=type_traits-dos.tar.bz2&directory=Extension& - sandbox: http://svn.boost.org/svn/boost/sandbox/type_traits/
Frédéric
Is the content different? Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/type-traits-extension-has-operator-xxx-co... Sent from the Boost - Dev mailing list archive at Nabble.com.

Don't use dependent default parameters for non-type template parameters. For example:
template <class T, int I = ::boost::is_integral<T>::value> // Error can't deduce value of I in some cases. struct foobar;
Rationale: this kind of usage fails for Borland C++. Note that this is only an issue where the default value is dependent upon a previous template parameter, for example the following is fine:
Is there any known workaround for this? In my case, int is replaced by bool but I think it is the same issue.
I'm not sure if that's still an issue for current compilers, but the workaround would be: template <class T, bool b> struct bar{ /*actual implementation here*/ }; template <class T> struct foo : public bar<T, ::boost::is_integral<T>::value> {} HTH, John.
participants (8)
-
Beman Dawes
-
Daniel James
-
Frédéric Bron
-
Ioannis Papadopoulos
-
Jeffrey Lee Hellrung, Jr.
-
John Maddock
-
Steven Watanabe
-
Vicente Botet