From 1700906ebfa7ee1fb50bc65570c41e80ada8e284 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Fri, 6 Oct 2017 15:48:21 +0200 Subject: [PATCH 1/2] Fix std::make_unique compilation errors on Windows This fixes the following errors: ``` TRootDS.cxx(145): error C2668: 'std::make_unique': ambiguous call to overloaded function [TreePlayer.vcxproj] C:\Users\bellenot\build\master-check\include\ROOT/RMakeUnique.hxx(26): note: could be 'std::unique_ptr> std::make_unique(std::string_view &,std::string_view &)' with [ _Ty=ROOT::Experimental::TDF::TRootDS ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\memory(2436): note: or 'std::unique_ptr> std::make_unique(std::string_view &,std::string_view &)' with [ _Ty=ROOT::Experimental::TDF::TRootDS ] TRootDS.cxx(145): note: while trying to match the argument list '(std::string_view, std::string_view)' TRootDS.cxx(145): error C2512: 'ROOT::Experimental::TDataFrame::TDataFrame': no appropriate default constructor available [TreePlayer.vcxproj] TTrivialDS.cxx TTrivialDS.cxx(82): error C2668: 'std::make_unique': ambiguous call to overloaded function [TreePlayer.vcxproj] C:\Users\bellenot\build\master-check\include\ROOT/RMakeUnique.hxx(26): note: could be 'std::unique_ptr> std::make_unique(ULong64_t &)' with [ _Ty=ROOT::Experimental::TDF::TTrivialDS ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\memory(2436): note: or 'std::unique_ptr> std::make_unique(ULong64_t &)' with [ _Ty=ROOT::Experimental::TDF::TTrivialDS ] TTrivialDS.cxx(82): note: while trying to match the argument list '(ULong64_t)' TTrivialDS.cxx(82): error C2512: 'ROOT::Experimental::TDataFrame::TDataFrame': no appropriate default constructor available [TreePlayer.vcxproj] ``` --- tree/treeplayer/src/TRootDS.cxx | 4 ++++ tree/treeplayer/src/TTrivialDS.cxx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tree/treeplayer/src/TRootDS.cxx b/tree/treeplayer/src/TRootDS.cxx index 34979b619344b..f2295c66cbc2a 100644 --- a/tree/treeplayer/src/TRootDS.cxx +++ b/tree/treeplayer/src/TRootDS.cxx @@ -139,7 +139,11 @@ void TRootDS::SetNSlots(unsigned int nSlots) TDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob) { +#ifdef R__WIN32 + ROOT::Experimental::TDataFrame tdf(std::unique_ptr(new TRootDS(treeName, fileNameGlob))); +#else ROOT::Experimental::TDataFrame tdf(std::make_unique(treeName, fileNameGlob)); +#endif return tdf; } diff --git a/tree/treeplayer/src/TTrivialDS.cxx b/tree/treeplayer/src/TTrivialDS.cxx index acd09eb082511..3690ab24ac249 100644 --- a/tree/treeplayer/src/TTrivialDS.cxx +++ b/tree/treeplayer/src/TTrivialDS.cxx @@ -76,7 +76,11 @@ void TTrivialDS::SetNSlots(unsigned int nSlots) TDataFrame MakeTrivialDataFrame(ULong64_t size) { +#ifdef R__WIN32 + ROOT::Experimental::TDataFrame tdf(std::unique_ptr(new TTrivialDS(size))); +#else ROOT::Experimental::TDataFrame tdf(std::make_unique(size)); +#endif return tdf; } From 7e359df7976cfe4adecb210d95f7293b486b0df4 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Fri, 6 Oct 2017 16:40:03 +0200 Subject: [PATCH 2/2] Use std::make_unique() from the system (__cplusplus is not reliable on Windows !!!) --- core/foundation/inc/ROOT/RMakeUnique.hxx | 2 +- tree/treeplayer/src/TRootDS.cxx | 4 ---- tree/treeplayer/src/TTrivialDS.cxx | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/core/foundation/inc/ROOT/RMakeUnique.hxx b/core/foundation/inc/ROOT/RMakeUnique.hxx index 86fa4381d26b3..d30e45ebbd0ad 100644 --- a/core/foundation/inc/ROOT/RMakeUnique.hxx +++ b/core/foundation/inc/ROOT/RMakeUnique.hxx @@ -16,7 +16,7 @@ #include -#if __cplusplus < 201402L +#if ((__cplusplus < 201402L && !defined(R__WIN32)) || (defined(_MSC_VER) && _MSC_VER < 1800)) #include diff --git a/tree/treeplayer/src/TRootDS.cxx b/tree/treeplayer/src/TRootDS.cxx index f2295c66cbc2a..34979b619344b 100644 --- a/tree/treeplayer/src/TRootDS.cxx +++ b/tree/treeplayer/src/TRootDS.cxx @@ -139,11 +139,7 @@ void TRootDS::SetNSlots(unsigned int nSlots) TDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob) { -#ifdef R__WIN32 - ROOT::Experimental::TDataFrame tdf(std::unique_ptr(new TRootDS(treeName, fileNameGlob))); -#else ROOT::Experimental::TDataFrame tdf(std::make_unique(treeName, fileNameGlob)); -#endif return tdf; } diff --git a/tree/treeplayer/src/TTrivialDS.cxx b/tree/treeplayer/src/TTrivialDS.cxx index 3690ab24ac249..acd09eb082511 100644 --- a/tree/treeplayer/src/TTrivialDS.cxx +++ b/tree/treeplayer/src/TTrivialDS.cxx @@ -76,11 +76,7 @@ void TTrivialDS::SetNSlots(unsigned int nSlots) TDataFrame MakeTrivialDataFrame(ULong64_t size) { -#ifdef R__WIN32 - ROOT::Experimental::TDataFrame tdf(std::unique_ptr(new TTrivialDS(size))); -#else ROOT::Experimental::TDataFrame tdf(std::make_unique(size)); -#endif return tdf; }