Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Willers
KWSys
Commits
b825c704
Commit
b825c704
authored
18 years ago
by
Brad King
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Implemented auto_ptr_ref in a way that allows conversion of the pointed-to type.
parent
602e60ef
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
auto_ptr.hxx.in
+5
-5
5 additions, 5 deletions
auto_ptr.hxx.in
testAutoPtr.cxx
+1
-4
1 addition, 4 deletions
testAutoPtr.cxx
with
6 additions
and
9 deletions
auto_ptr.hxx.in
+
5
−
5
View file @
b825c704
...
...
@@ -26,14 +26,14 @@ namespace detail
// a private namespace.
template <class Y> struct auto_ptr_ref
{
auto_ptr<Y>&
p_;
Y*
p_;
// The extra constructor argument prevents implicit conversion to
// auto_ptr_ref from auto_ptr through the constructor. Normally
// this should be done with the explicit keyword but Borland 5.x
// generates code in the conversion operator to call itself
// infinately.
auto_ptr_ref(
auto_ptr<Y>&
p, int): p_(p) {}
auto_ptr_ref(
Y*
p, int): p_(p) {}
};
}
...
...
@@ -136,7 +136,7 @@ public:
/** Construct from an auto_ptr_ref. This is used when the
constructor argument is a call to a function returning an
auto_ptr. */
auto_ptr(detail::auto_ptr_ref<X> r) throw(): x_(r.p_
.release()
)
auto_ptr(detail::auto_ptr_ref<X> r) throw(): x_(r.p_)
{
}
...
...
@@ -145,7 +145,7 @@ public:
another auto_ptr. */
template <class Y> operator detail::auto_ptr_ref<Y>() throw()
{
return detail::auto_ptr_ref<Y>(
*
this, 1);
return detail::auto_ptr_ref<Y>(this
->release()
, 1);
}
/** Convert to an auto_ptr holding an object of a compatible type.
...
...
@@ -160,7 +160,7 @@ public:
assignment. */
auto_ptr& operator=(detail::auto_ptr_ref<X> r) throw()
{
this->reset(r.p_
.release()
);
this->reset(r.p_);
return *this;
}
};
...
...
This diff is collapsed.
Click to expand it.
testAutoPtr.cxx
+
1
−
4
View file @
b825c704
...
...
@@ -123,6 +123,7 @@ int testAutoPtr(int, char*[])
}
#if 0
// Is this allowed by the standard?
{
int received = function_call(generate_auto_ptr_B());
ASSERT(received,
...
...
@@ -144,22 +145,18 @@ int testAutoPtr(int, char*[])
"auto_ptr empty after assignment from factory function"
);
}
#if 0
{
kwsys
::
auto_ptr
<
A
>
pa
(
generate_auto_ptr_B
());
ASSERT
(
pa
.
get
(),
"auto_ptr empty after construction from compatible factory function"
);
}
#endif
#if 0
{
kwsys
::
auto_ptr
<
A
>
pa
;
pa
=
generate_auto_ptr_B
();
ASSERT
(
pa
.
get
(),
"auto_ptr empty after assignment from compatible factory function"
);
}
#endif
}
ASSERT
(
instances
==
0
,
"auto_ptr leaked an object"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment