Subject: bug report of nested template or possible decltype hiccup. I lean toward decltype being the problem because the false_type is happy. Or maybe it's the & (there could also be a * btw).
/* primary template handles types that have no nested ::var variable */
template <class, class = std::void_t<>>
struct has_var : std::false_type { };
/* specialization recognizes types that do have a nested ::var variable */
template <class T>
struct has_var<T, std::void_t<decltype(&T::var)>> : std::true_type { };
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In a vanilla index.rst:
.. cpp:class:: template <class, class = std::void_t<>> has_var
Trap state, inherits from ``std::false_type``.
.. cpp:class:: template <class T> has_var<T, std::void_t<decltype(&T::var)>>
Specialization for when ``T::var`` exists, inherits from ``std::true_type``.
Sphinx 1.6.4:
WARNING: Index id generation for C++ object "template<class T> has_var<T, std::void_t<decltype(&T::var)>>" failed, please report as bug (id=_CPPv2I0E7has_varI1TNSt6void_tIXdecltype(&T::var)EEEE).
For what it's worth, Sphinx 1.6.3's behavior here may actually be better (?). I whittled this down for using pure sphinx directives. I actually came here from a Breathe directive
.. doxygenstruct:: has_video_height< T, std::void_t< decltype(&T::video_height)> >
:members:
:protected-members:
:undoc-members:
1.6.3 will warn but accept, 1.6.4 errors out on assert False in checkType.
The 1.6.3 implementation is different. The diff
--- 163 2017-09-28 11:03:09.000000000 -0700
+++ 164 2017-09-28 11:03:13.000000000 -0700
@@ -3,14 +3,8 @@
return True
if declTyp == 'templateParam':
return True
- if typ == 'var' or typ == 'member':
- return declTyp in ['var', 'member']
- if typ in ['enum', 'enumerator', 'function', 'class', 'concept']:
- return declTyp == typ
- validForType = ['enum', 'class', 'function', 'type']
- if typ == 'typeOrConcept':
- return declTyp == 'concept' or declTyp in validForType
- if typ == 'type':
- return declTyp in validForType
- print("Type is %s" % typ)
+ objtypes = self.objtypes_for_role(typ)
+ if objtypes and declTyp in objtypes:
+ return True
+ print("Type is %s, declType is %s" % (typ, declTyp))
assert False
But I'm honestly pretty lost on how one assert False (in 1.6.4), but the other doesn't...
Please let me know if you'd like me to make a full-fledged example repo (e.g. the problem isn't obvious to you the sphinx-gods) and I will. Breathe requires extra setup (running doxygen, etc).
No link error?
Just paste the rst above in any sphinx project.
Thanks for reporting, there are quite a few things:
expr role for inline text to be parsed and hyperlinked).std::void_t<>) which should be fixed now.decltype(<expr>) parsing is not enabled on master yet, so a hard error instead of a warning will be triggered (though that error message has problems as well). I will see if I can get it enabled soon.checkType problem arose, or how to reproduce it. Can you open a separate bug report for that? Is the project where it occurs publicly available?The master branch had a bug with empty template argument lists (e.g., in std::void_t<>) which should be fixed now.
Righto!
However, general decltype(
) parsing is not enabled on master yet, so a hard error instead of a warning will be triggered (though that error message has problems as well). I will see if I can get it enabled soon.
Hmm. Well, to be honest I am really confused now and think this statement may not be accurate.
.. cpp:class:: template <class T> has_var<T, internal::void_t<decltype(&T::var)>>
specialization recognizes types that do have a nested ``var`` variable
Works...
I'm not sure how the checkType problem arose, or how to reproduce it. Can you open a separate bug report for that? Is the project where it occurs publicly available?
Flabbergasted is probably the right answer here. I can't reproduce this anymore either. I made a testing repository, but am now no longer able to even get Breathe to find the has_var that uses decltype(&T::var).
I started in on all of this from breathe/#354, wanting to fix template specializations and using statements. I'm gonna have to put this down for a bit, if I'm actually able to reproduce this I'll open the new issue...but until I can get Breathe to actually find things, I can't get the assert False to fail out :cry:
But I'm honestly pretty lost on how one
assert False(in 1.6.4), but the other doesn't...
This is fixed in my pull request #4096.
Parsing of decltype(<expr>) should now work in the master branch.