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

Components have to be default constructible #2848

Closed
krivenko opened this issue Aug 18, 2017 · 0 comments · Fixed by #2851
Closed

Components have to be default constructible #2848

krivenko opened this issue Aug 18, 2017 · 0 comments · Fixed by #2851

Comments

@krivenko
Copy link

Here is another problem related to types without an accessible default constructor.
tests/unit/component/new_.cpp does not compile after it's changed like this,

diff --git a/tests/unit/component/new_.cpp b/tests/unit/component/new_.cpp
index 16185e1fa3..341e858dd4 100644
--- a/tests/unit/component/new_.cpp
+++ b/tests/unit/component/new_.cpp
@@ -15,8 +15,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 struct test_server : hpx::components::simple_component_base<test_server>
 {
+    test_server() = delete;
+    test_server(int i) : i(i) {}
     hpx::id_type call() const { return hpx::find_here(); }
 
+    int i;
+
     HPX_DEFINE_COMPONENT_ACTION(test_server, call);
 };                                                                                                                                                                                       
                                                                                                                                                                                          
@@ -49,7 +53,7 @@ void test_create_single_instance()                                                                                                                                      
     // make sure created objects live on locality they are supposed to be                                                                                                                
     for (hpx::id_type const& loc: hpx::find_all_localities())                                                                                                                            
     {                                                                                                                                                                                    
-        hpx::id_type id = hpx::new_<test_server>(loc).get();                                                                                                                             
+        hpx::id_type id = hpx::new_<test_server>(loc, 42).get();                                                                                                                         
         HPX_TEST(hpx::async<call_action>(id).get() == loc);                                                                                                                              
     }                                                                                                                                                                                    
                                                                                                                                                                                          
@@ -60,7 +64,7 @@ void test_create_single_instance()                                                                                                                                      
     }                                                                                                                                                                                    
                                                                                                                                                                                          
     // make sure distribution policy is properly used                                                                                                                                    
-    hpx::id_type id = hpx::new_<test_server>(hpx::default_layout).get();                                                                                                                 
+    hpx::id_type id = hpx::new_<test_server>(hpx::default_layout, 42).get();                                                                                                             
     HPX_TEST(hpx::async<call_action>(id).get() == hpx::find_here());
 
     test_client t2 = hpx::new_<test_client>(hpx::default_layout);
@@ -68,7 +72,7 @@ void test_create_single_instance()
 
     for (hpx::id_type const& loc: hpx::find_all_localities())
     {
-        hpx::id_type id = hpx::new_<test_server>(hpx::default_layout(loc)).get();
+        hpx::id_type id = hpx::new_<test_server>(hpx::default_layout(loc), 42).get();
         HPX_TEST(hpx::async<call_action>(id).get() == loc);
     }
 
@@ -85,7 +89,7 @@ void test_create_multiple_instances()
     // make sure created objects live on locality they are supposed to be
     for (hpx::id_type const& loc: hpx::find_all_localities())
     {
-        std::vector<hpx::id_type> ids = hpx::new_<test_server[]>(loc, 10).get();
+        std::vector<hpx::id_type> ids = hpx::new_<test_server[]>(loc, 10, 42).get();
         HPX_TEST_EQ(ids.size(), std::size_t(10));
 
         for (hpx::id_type const& id: ids)
@@ -96,7 +100,7 @@ void test_create_multiple_instances()
 
     for (hpx::id_type const& loc: hpx::find_all_localities())
     {
-        std::vector<test_client> ids = hpx::new_<test_client[]>(loc, 10).get();
+        std::vector<test_client> ids = hpx::new_<test_client[]>(loc, 10, 42).get();
         HPX_TEST_EQ(ids.size(), std::size_t(10));
 
         for (test_client const& c: ids)
@@ -107,7 +111,7 @@ void test_create_multiple_instances()
 
     // make sure distribution policy is properly used
     std::vector<hpx::id_type> ids =
-        hpx::new_<test_server[]>(hpx::default_layout, 10).get();
+        hpx::new_<test_server[]>(hpx::default_layout, 10, 42).get();
     HPX_TEST_EQ(ids.size(), std::size_t(10));
     for (hpx::id_type const& id: ids)
     {
@@ -115,7 +119,7 @@ void test_create_multiple_instances()
     }
 
     std::vector<test_client> clients =
-        hpx::new_<test_client[]>(hpx::default_layout, 10).get();
+        hpx::new_<test_client[]>(hpx::default_layout, 10, 42).get();
     HPX_TEST_EQ(clients.size(), std::size_t(10));
     for (test_client const& c: clients)
     {
@@ -125,7 +129,7 @@ void test_create_multiple_instances()
     for (hpx::id_type const& loc: hpx::find_all_localities())
     {
         std::vector<hpx::id_type> ids =
-            hpx::new_<test_server[]>(hpx::default_layout(loc), 10).get();
+            hpx::new_<test_server[]>(hpx::default_layout(loc), 10, 42).get();
         HPX_TEST_EQ(ids.size(), std::size_t(10));
 
         for (hpx::id_type const& id: ids)
@@ -137,7 +141,7 @@ void test_create_multiple_instances()
     for (hpx::id_type const& loc: hpx::find_all_localities())
     {
         std::vector<test_client> ids =
-            hpx::new_<test_client[]>(hpx::default_layout(loc), 10).get();
+            hpx::new_<test_client[]>(hpx::default_layout(loc), 10, 42).get();
         HPX_TEST_EQ(ids.size(), std::size_t(10));
 
         for (test_client const& c: ids)
hpx.git/hpx/runtime/components/server/simple_component_base.hpp:304:64: error: use of deleted function ‘test_server::test_server()’
             return static_cast<component_type*>(new Component()); //-V572
                                                                ^
hpx.git/tests/unit/component/new_.cpp:18:5: note: declared here
     test_server() = delete;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants