std::endl()
note that this does not happen during the completion of std::cout !simple answer:
// [27.6.2.7] standard basic_ostream manipulatorsThis is a function!
/**
* @brief Write a newline and flush the stream.
*
* This manipulator is often mistakenly used when a simple newline is
* desired, leading to poor buffering performance. See
* http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#2 for more
* on this subject.
*/
template<typename _CharT, typename _Traits>
inline basic_ostream<_CharT, _Traits>&
endl(basic_ostream<_CharT, _Traits>& __os)
{ return flush(__os.put(__os.widen('\n'))); }
#if _GLIBCXX_EXTERN_TEMPLATEHere is a variable.
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
But in:ostream.tcc (LINE: 361 or 384)our parser just recognize this "endl" as a function, because it has some grammar mode:Quote#if _GLIBCXX_EXTERN_TEMPLATEHere is a variable.
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
AAAA BBBB();
But in:ostream.tcc (LINE: 361 or 384)our parser just recognize this "endl" as a function, because it has some grammar mode:Quote#if _GLIBCXX_EXTERN_TEMPLATEHere is a variable.
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);CodeAAAA BBBB();
Index: src/plugins/codecompletion/codecompletion.cpp
===================================================================
--- src/plugins/codecompletion/codecompletion.cpp (revision 6543)
+++ src/plugins/codecompletion/codecompletion.cpp (working copy)
@@ -790,7 +790,8 @@
items.Add(tmp);
if (autoAddParentheses && token->m_TokenKind == tkFunction)
{
- m_SearchItem[token->m_Name] = token->m_Args.size() - 2;
+ if (token->m_Name != _T("endl"))
+ m_SearchItem[token->m_Name] = token->m_Args.size() - 2;
}
if (token->m_TokenKind == tkNamespace && token->m_Aliases.size())
{
__ostream_type&
operator<<(__ostream_type& (*__pf)(__ostream_type&))
std::endl *is* a function.
When people are typing std::endl they are actually passing the pointer of the function to the 'operator <<' of class basic_ostreamCode__ostream_type&
operator<<(__ostream_type& (*__pf)(__ostream_type&))
The same is true for all other similar methods, like std::hex, std::oct, std::dec etc
So if you are going to special handle the 'endl' case, make sure you handle the other methods as well (hex, dec, oct etc.)
Eran
So, my personal question is: how does Codelite deal with this kind of problem??I am not :D
QuoteSo, my personal question is: how does Codelite deal with this kind of problem??I am not :D
The same as codeblocks:The other is special handling like: (endl, hex, dec, oct etc)
when user types std::endl -> codelite adds the () and shows the function tip. I never find it a problem since in codelite if I delete the open brace, the closing brace is also deleted
Looks can only judge of the special?No good. Imagine you have a local variable / method with this name than endl has a different meaning and appending the brackets might be desired. In addition: actually this codecompletion should not have any language specific elements at all... ;-)
Well, we still remain the same.Looks can only judge of the special?No good. Imagine you have a local variable / method with this name than endl has a different meaning and appending the brackets might be desired. In addition: actually this codecompletion should not have any language specific elements at all... ;-)
maybe, a better way is :I think this is not possible!
checking the ”<<" can accept a function pointer, then we can avoid adding "()" in this case. But it is too complex :D
std::endl *is* a function.Thank eranif to help!
When people are typing std::endl they are actually passing the pointer of the function to the 'operator <<' of class basic_ostreamCode__ostream_type&
operator<<(__ostream_type& (*__pf)(__ostream_type&))
The same is true for all other similar methods, like std::hex, std::oct, std::dec etc
So if you are going to special handle the 'endl' case, make sure you handle the other methods as well (hex, dec, oct etc.)
Eran
Thank eranif to help!It can. But I simply prefered not to use it but rather using wxToolbar (wxAuiToolBar is simply *ugly* under Linux, it looks like it was written for Windows and then ported to Linux/Mac)
Another question, Why CodeLite can not use wxAuiToolBar on Linux?
Well, thank you!QuoteThank eranif to help!It can. But I simply prefered not to use it but rather using wxToolbar (wxAuiToolBar is simply *ugly* under Linux, it looks like it was written for Windows and then ported to Linux/Mac)
Another question, Why CodeLite can not use wxAuiToolBar on Linux?
If you really insist on enabling it, you can simply change it in the file cl_defs.h yo USE_AUI_TOOLBAR=1
Eran