Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Resource Constructor Explicit #150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/camp/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace resources
typename = typename std::enable_if<
!std::is_same<typename std::decay<T>::type,
Resource>::value>::type>
Resource(T &&value)
explicit Resource(T &&value)
{
m_value.reset(new ContextModel<type::ref::rem<T>>(forward<T>(value)));
}
Expand Down
8 changes: 4 additions & 4 deletions test/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ TEST(CampResource, Reassignment)
{
Resource h1{Host()};
Resource c1{Cuda()};
h1 = Cuda();
h1 = Resource{Cuda()};
ASSERT_EQ(typeid(c1), typeid(h1));

Resource h2{Host()};
Resource c2{Cuda()};
c2 = Host();
c2 = Resource{Host()};
ASSERT_EQ(typeid(c2), typeid(h2));
}

Expand Down Expand Up @@ -148,12 +148,12 @@ TEST(CampResource, Reassignment)
{
Resource h1{Host()};
Resource c1{Hip()};
h1 = Hip();
h1 = Resource{Hip()};
ASSERT_EQ(typeid(c1), typeid(h1));

Resource h2{Host()};
Resource c2{Hip()};
c2 = Host();
c2 = Resource{Host()};
ASSERT_EQ(typeid(c2), typeid(h2));
}

Expand Down