Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
CC no longer working for unique_ptr
killerbot:
I can confirm that the first problem is solved : foo.
But the second one still fails : bar->
Loaden:
--- Quote from: killerbot on August 30, 2011, 08:25:59 pm ---I can confirm that the first problem is solved : foo.
But the second one still fails : bar->
--- End quote ---
About the second issue: shared_ptr<Test> and auto_ptr<Test> works well.
So, There should has some thing changed with unique_ptr.
Loaden:
I can't solved this issue. It's too complex.
--- Code: ---/// 20.7.12.2 unique_ptr for single objects.
template <typename _Tp, typename _Dp = default_delete<_Tp> >
class unique_ptr
{
// use SFINAE to determine whether _Del::pointer exists
class _Pointer
{
template<typename _Up>
static typename _Up::pointer __test(typename _Up::pointer*);
template<typename _Up>
static _Tp* __test(...);
typedef typename remove_reference<_Dp>::type _Del;
public:
typedef decltype( __test<_Del>(0)) type;
};
typedef std::tuple<typename _Pointer::type, _Dp> __tuple_type;
__tuple_type _M_t;
public:
typedef typename _Pointer::type pointer;
...
pointer
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(get() != pointer());
return get();
}
--- End code ---
See: typedef typename _Pointer::type pointer;
I don't understood what's the meaning.
If change to:
--- Code: --- _Tp*
operator->() const
{
_GLIBCXX_DEBUG_ASSERT(get() != pointer());
return get();
}
--- End code ---
Every thing will works fine.
ollydbg:
--- Code: ---typedef typename _Pointer::type pointer;
--- End code ---
we should resolve the actual type of the string "_Pointer::type".
As the definition of the embedded class _Pointer, "_Pointer::type" is actually a type from the "decltype operator" deduced from the expression "__test<_Del>(0)".
Then "__test<_Del>(0)" is a function calling expression defined by
--- Code: ---template<typename _Up>
static _Tp* __test(...);
--- End code ---
So, it's actual type is "_Tp*".
As a conclusion: C++'s type-deduction mechanism is heaven for programmer, but it is the hell for compiler/parser writer. :D, each step should involve the symbol table check and semantics check.
I don't think it can be implemented in CC, it was too complex.
Navigation
[0] Message Index
[*] Previous page
Go to full version