diff --git a/src/libmarqov/core.h b/src/libmarqov/core.h index 82c0e0e191907a378848f15088bda5d426cb7371..fd08a0b35252db5f9f75da76beb672a8b056d260 100644 --- a/src/libmarqov/core.h +++ b/src/libmarqov/core.h @@ -214,7 +214,7 @@ namespace MARQOV * @param args additional arguments that just get eaten. */ template - Ref(const L&& lattice, Args&& ... args) : grid(lattice) {} + Ref(const L& lattice, Args&& ... args) : grid(lattice) {} const L& grid; ///< A reference to the external lattice. Note that the name is the same as in NonRef. }; @@ -232,23 +232,22 @@ namespace MARQOV * * @tparam Args The parameter pack of the lattice parameters. * - * @param args the actual lattice Arguments. + * @param args the actual lattice arguments. */ template - NonRef(std::tuple&& args ) : NonRef(std::forward>(args), - std::make_index_sequence>::type>::value>()) {} + NonRef(std::tuple args) : NonRef(args, std::make_index_sequence>::value>()) {} /** Constructor to do the parameter unpacking.. * * @tparam Args The parameter pack of the lattice parameters. - * @tparam S an integer pack. + * @tparam S an integer sequence. * - * @param args the actual lattice Arguments. + * @param args the actual lattice arguments. */ template - NonRef(std::tuple&& args, std::index_sequence) : grid(std::get(std::forward>(args))... ) {} + NonRef(std::tuple args, std::index_sequence) : grid(std::get(args)... ) {} - const L grid;///< The storage of the Lattice. Note that the name is the same as in Ref. + const L grid;///< The storage of the Lattice. Note that the name of the variable is the same as in detail::Ref. }; /** Helper to decide whether a Hamiltonian provides an init function. @@ -540,8 +539,8 @@ class Core : public RefType * @param hargs A template parameter pack for the Hamiltonian. */ template - Core(Grid&& lattice, Config mc, MutexType& mtx, double mybeta, HArgs&& ... hargs) : - RefType(std::forward(lattice)), + Core(const Grid& lattice, Config mc, MutexType& mtx, double mybeta, HArgs&& ... hargs) : + RefType(lattice), beta(mybeta), ham(std::forward(hargs) ... ), mcfg(mc), @@ -578,8 +577,8 @@ class Core : public RefType * @param hargs the arguemts for the Hamiltonian. */ template - Core(std::tuple&& largs, Config mc, MutexType& mtx, double mybeta, HArgs&& ... hargs) : - RefType(std::forward>(largs)), + Core(std::tuple largs, Config mc, MutexType& mtx, double mybeta, HArgs&& ... hargs) : + RefType(largs), beta(mybeta), ham(std::forward(hargs) ... ), mcfg(mc), @@ -1213,9 +1212,9 @@ class Core : public RefType * @param hargs The hamiltonian arguments. */ template -inline constexpr auto makeCore_with_latt(const Config& mc, MutexType& mtx, std::tuple&& largs, const std::tuple hargs, std::index_sequence ) +inline constexpr auto makeCore_with_latt(const Config& mc, MutexType& mtx, const std::tuple& largs, const std::tuple hargs, std::index_sequence ) { - return Core(std::forward>(largs), mc, mtx, std::get(hargs)...); + return Core(largs, mc, mtx, std::get(hargs)...); } /** Instantiate Core and use a reference to a precreated lattice. @@ -1234,7 +1233,7 @@ inline constexpr auto makeCore_with_latt(const Config& mc, MutexType& mtx, std:: * @param hargs The hamiltonian arguments. */ template -inline constexpr auto makeCore_using_latt(Grid&& latt, const Config& mc, MutexType& mtx, std::tuple hargs, std::index_sequence) +inline constexpr auto makeCore_using_latt(Grid&& latt, const Config& mc, MutexType& mtx, const std::tuple& hargs, std::index_sequence) { return Core(std::forward(latt), mc, mtx, std::get(hargs)...); } @@ -1250,13 +1249,11 @@ inline constexpr auto makeCore_using_latt(Grid&& latt, const Config& mc, MutexTy * @param mtx The mutex that synchronizes access to the HDF5 files. */ template -inline auto makeCore(const std::tuple > t, MutexType& mtx=tm) +inline auto makeCore(const std::tuple >& t, MutexType& mtx=tm) { //The first argument is a Lattice-like type -> from this we infer that //we get a reference to sth. already allocated - return makeCore_using_latt(std::forward(std::get<0>(t)), std::get<1>(t), mtx, std::get<2>(t), - std::make_index_sequence>::type>::value>() - ); + return makeCore_using_latt(std::forward(std::get<0>(t)), std::get<1>(t), mtx, std::get<2>(t), std::make_index_sequence>::value>()); } /** Instantiate Core and let it create the lattice. @@ -1270,49 +1267,10 @@ inline auto makeCore(const std::tuple > t, M * @param mtx The mutex that synchronizes access to the HDF5 files. */ template -inline auto makeCore(std::tuple, Config, std::tuple > t, std::mutex& mtx) +inline auto makeCore(const std::tuple, Config, std::tuple >& t, std::mutex& mtx) { - return makeCore_with_latt(std::get<1>(t), mtx, std::forward >(std::get<0>(t)), std::get<2>(t), - std::make_index_sequence>::type>::value>() - ); -} - -/** Instantiate Core and let it create the lattice. - * - * @tparam H the type of Hamiltonian - * @tparam Grid the type of the lattice - * @tparam LArgs The arguments of the lattice. - * @tparam HArgs the arguments of the hamiltonian. - * - * @param t a tuple of a reference of lattice parameters, a config object and the hamiltonian parameters. - * @param mtx The mutex that synchronizes access to the HDF5 files. - */ -template -inline constexpr auto makeCore(std::tuple&, Config, std::tuple > t, std::mutex& mtx) -{ - return makeCore_with_latt(std::get<1>(t), mtx, std::forward >(std::get<0>(t)), std::get<2>(t), - std::make_index_sequence>::type>::value>() - ); -} - -/** Instantiate Core and let it create the lattice. - * - * This overload improves compatibility with decltype and gives a more - * consistent user experience. - * @tparam H the type of Hamiltonian - * @tparam Grid the type of the lattice - * @tparam LArgs The arguments of the lattice. - * @tparam HArgs the arguments of the hamiltonian. - * - * @param t a tuple of the lattice parameters, a config object and the hamiltonian parameters. - * @param mtx The mutex that synchronizes access to the HDF5 files. - */ -template -inline auto makeCore(std::tuple, Config, std::tuple& > t, std::mutex& mtx) -{ - return makeCore_with_latt(std::get<1>(t), mtx, std::forward >(std::get<0>(t)), std::get<2>(t), - std::make_index_sequence>::type>::value>() - ); + return makeCore_with_latt(std::get<1>(t), mtx, std::get<0>(t), std::get<2>(t), + std::make_index_sequence>::value>()); } }