diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc
index 32515f83d525671ab13d4b957f21674572819ff6..5fc1ef0bc61b7522d0308ad9e5dd2c858765ce09 100644
--- a/mex/sources/bytecode/Interpreter.cc
+++ b/mex/sources/bytecode/Interpreter.cc
@@ -588,7 +588,7 @@ Interpreter::simulate_a_block(
               res1 = 0;
               max_res = 0;
               max_res_idx = 0;
-              copy_n(y, y_size * (periods + y_kmax + y_kmin), y_save);
+              ranges::copy_n(y, y_size * (periods + y_kmax + y_kmin), y_save);
               if (vector_table_conditional_local.size())
                 for (auto& it1 : vector_table_conditional_local)
                   if (it1.is_cond)
@@ -597,7 +597,7 @@ Interpreter::simulate_a_block(
               if (!(isnan(res1) || isinf(res1)))
                 cvg = (max_res < solve_tolf);
               if (isnan(res1) || isinf(res1) || (stack_solve_algo == 4 && iter > 0))
-                copy_n(y_save, y_size * (periods + y_kmax + y_kmin), y);
+                ranges::copy_n(y_save, y_size * (periods + y_kmax + y_kmin), y);
               u_count = u_count_saved;
               int prev_iter = iter;
               Simulate_Newton_Two_Boundaries(cvg, vector_table_conditional_local);
@@ -4346,10 +4346,10 @@ Interpreter::Simulate_One_Boundary()
               Ax_save = static_cast<double*>(mxMalloc(Ap[size] * sizeof(double)));
               test_mxMalloc(Ax_save, __LINE__, __FILE__, __func__, Ap[size] * sizeof(double));
             }
-          copy_n(Ap, size + 1, Ap_save);
-          copy_n(Ai, Ap[size], Ai_save);
-          copy_n(Ax, Ap[size], Ax_save);
-          copy_n(b, size, b_save);
+          ranges::copy_n(Ap, size + 1, Ap_save);
+          ranges::copy_n(Ai, Ap[size], Ai_save);
+          ranges::copy_n(Ax, Ap[size], Ax_save);
+          ranges::copy_n(b, size, b_save);
         }
     }
   if (zero_solution)
diff --git a/mex/sources/bytecode/bytecode.cc b/mex/sources/bytecode/bytecode.cc
index e3c244ab96d870348de344a22542119fe630bd5c..b11efc99b6771d1c3bbfb9a6a5fc6f1364e69079 100644
--- a/mex/sources/bytecode/bytecode.cc
+++ b/mex/sources/bytecode/bytecode.cc
@@ -519,9 +519,9 @@ mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
   test_mxMalloc(x, __LINE__, __FILE__, __func__, col_x * row_x * sizeof(double));
 
   fill_n(direction, row_y * col_y, 0);
-  copy_n(xd, row_x * col_x, x);
-  copy_n(yd, row_y * col_y, y);
-  copy_n(yd, row_y * col_y, ya);
+  ranges::copy_n(xd, row_x * col_x, x);
+  ranges::copy_n(yd, row_y * col_y, y);
+  ranges::copy_n(yd, row_y * col_y, ya);
 
   const filesystem::path codfile {file_name + "/model/bytecode/"
                                   + (block_decomposed ? "block/" : "")
@@ -585,7 +585,7 @@ mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
         {
           int out_periods = extended_path ? max_periods + y_kmin : col_y;
           plhs[0] = mxCreateDoubleMatrix(row_y, out_periods, mxREAL);
-          std::copy_n(y, row_y * out_periods, mxGetPr(plhs[0]));
+          std::ranges::copy_n(y, row_y * out_periods, mxGetPr(plhs[0]));
         }
       if (nlhs > 1)
         {
diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc
index 9cf3232792536325a07453374ba3b7f9585dd2b6..bf94f076c78f709d769f2ebce214379022cbc701 100644
--- a/mex/sources/k_order_perturbation/k_order_perturbation.cc
+++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc
@@ -73,7 +73,7 @@ copy_derivatives(mxArray* destin, const Symmetry& sym, const FGSContainer& deriv
   int n = x_unfolded->nrows();
   int m = x_unfolded->ncols();
   mxArray* tmp = mxCreateDoubleMatrix(n, m, mxREAL);
-  std::copy_n(x_unfolded->getData().base(), n * m, mxGetPr(tmp));
+  std::ranges::copy_n(x_unfolded->getData().base(), n * m, mxGetPr(tmp));
   mxSetField(destin, 0, fieldname, tmp);
 }
 
@@ -289,7 +289,7 @@ extern "C"
             std::vector<std::string> g_fieldnames_pruning(g_fieldnames);
             g_fieldnames_pruning.emplace_back("pruning");
             const char* g_fieldnames_pruning_c[kOrder + 2];
-            std::copy_n(g_fieldnames_c, kOrder + 1, g_fieldnames_pruning_c);
+            std::ranges::copy_n(g_fieldnames_c, kOrder + 1, g_fieldnames_pruning_c);
             g_fieldnames_pruning_c[kOrder + 1] = g_fieldnames_pruning.back().c_str();
             plhs[0] = mxCreateStructMatrix(1, 1, kOrder + 2, g_fieldnames_pruning_c);
           }
@@ -303,7 +303,7 @@ extern "C"
             mxArray* tmp = mxCreateDoubleMatrix(t.nrows(), t.ncols(), mxREAL);
             const ConstVector& vec = t.getData();
             assert(vec.skip() == 1);
-            std::copy_n(vec.base(), vec.length(), mxGetPr(tmp));
+            std::ranges::copy_n(vec.base(), vec.length(), mxGetPr(tmp));
             mxSetField(plhs[0], 0, g_fieldnames_c[i], tmp);
           }
 
@@ -322,7 +322,7 @@ extern "C"
                 mxArray* tmp = mxCreateDoubleMatrix(t.nrows(), t.ncols(), mxREAL);
                 const ConstVector& vec = t.getData();
                 assert(vec.skip() == 1);
-                std::copy_n(vec.base(), vec.length(), mxGetPr(tmp));
+                std::ranges::copy_n(vec.base(), vec.length(), mxGetPr(tmp));
                 mxSetField(dr_pruning, 0, g_fieldnames_c[i], tmp);
               }
           }
diff --git a/mex/sources/k_order_welfare/k_order_welfare.cc b/mex/sources/k_order_welfare/k_order_welfare.cc
index b660b7648cf9eed9520624998cf025bd76b4c524..33436437d12ca843039117085f2c60cd11434edd 100644
--- a/mex/sources/k_order_welfare/k_order_welfare.cc
+++ b/mex/sources/k_order_welfare/k_order_welfare.cc
@@ -71,7 +71,7 @@ copy_derivatives(mxArray* destin, const Symmetry& sym, const FGSContainer& deriv
   int n = x_unfolded->nrows();
   int m = x_unfolded->ncols();
   mxArray* tmp = mxCreateDoubleMatrix(n, m, mxREAL);
-  std::copy_n(x_unfolded->getData().base(), n * m, mxGetPr(tmp));
+  std::ranges::copy_n(x_unfolded->getData().base(), n * m, mxGetPr(tmp));
   mxSetField(destin, 0, fieldname, tmp);
 }
 
@@ -363,7 +363,7 @@ extern "C"
         mxArray* tmp = mxCreateDoubleMatrix(t.nrows(), t.ncols(), mxREAL);
         const ConstVector& vec = t.getData();
         assert(vec.skip() == 1);
-        std::copy_n(vec.base(), vec.length(), mxGetPr(tmp));
+        std::ranges::copy_n(vec.base(), vec.length(), mxGetPr(tmp));
         mxSetField(plhs[0], 0, ("W_" + std::to_string(i)).c_str(), tmp);
       }
   } // end of mexFunction()
diff --git a/mex/sources/k_order_welfare/objective_m.cc b/mex/sources/k_order_welfare/objective_m.cc
index ff523d90bf9ff2d57ec9c61acc252b61fbf1abfa..8d6709e561aba526139976ea292240f2946cd4b6 100644
--- a/mex/sources/k_order_welfare/objective_m.cc
+++ b/mex/sources/k_order_welfare/objective_m.cc
@@ -46,13 +46,13 @@ ObjectiveMFile::eval(const Vector& y, const Vector& x, const Vector& modParams,
                      TensorContainer<FSSparseTensor>& derivatives) const
 {
   mxArray* y_mx = mxCreateDoubleMatrix(y.length(), 1, mxREAL);
-  std::copy_n(y.base(), y.length(), mxGetPr(y_mx));
+  std::ranges::copy_n(y.base(), y.length(), mxGetPr(y_mx));
 
   mxArray* x_mx = mxCreateDoubleMatrix(1, x.length(), mxREAL);
-  std::copy_n(x.base(), x.length(), mxGetPr(x_mx));
+  std::ranges::copy_n(x.base(), x.length(), mxGetPr(x_mx));
 
   mxArray* params_mx = mxCreateDoubleMatrix(modParams.length(), 1, mxREAL);
-  std::copy_n(modParams.base(), modParams.length(), mxGetPr(params_mx));
+  std::ranges::copy_n(modParams.base(), modParams.length(), mxGetPr(params_mx));
 
   mxArray *T_order_mx, *T_mx;
 
diff --git a/mex/sources/kalman_steady_state/kalman_steady_state.cc b/mex/sources/kalman_steady_state/kalman_steady_state.cc
index dd4446e000a0df31f74e1c746e8cb7f7c4e5ab46..74c5d8d765aad26d7a36e4ac482f7d46b8b2418d 100644
--- a/mex/sources/kalman_steady_state/kalman_steady_state.cc
+++ b/mex/sources/kalman_steady_state/kalman_steady_state.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2009-2020 Dynare Team.
+ * Copyright © 2009-2024 Dynare Team.
  *
  * This file is part of Dynare.
  *
@@ -119,11 +119,11 @@ mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
   // Get input matrices.
   const double* T = mxGetPr(prhs[0]);
   auto QQ = std::make_unique<double[]>(n * n);
-  std::copy_n(mxGetPr(prhs[1]), n * n, QQ.get());
+  std::ranges::copy_n(mxGetPr(prhs[1]), n * n, QQ.get());
   const double* Z = mxGetPr(prhs[2]);
   auto H = std::make_unique<double[]>(p * p);
   if (measurement_error_flag)
-    std::copy_n(mxGetPr(prhs[3]), p * p, H.get());
+    std::ranges::copy_n(mxGetPr(prhs[3]), p * p, H.get());
   // L will not be used.
   auto L = std::make_unique<double[]>(n * p);
   lapack_int nn = 2 * n;
diff --git a/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc b/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
index a8df4994274106a82da55a390ade07aa9cc10937..37a2e5ee9459e311c1f8c26af754cbfe6445c2df 100644
--- a/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
+++ b/mex/sources/kronecker/sparse_hessian_times_B_kronecker_C.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2007-2023 Dynare Team
+ * Copyright © 2007-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -80,7 +80,7 @@ sparse_hessian_times_B_kronecker_B(const mwIndex* isparseA, const mwIndex* jspar
                 }
             }
           if (nz_in_column_ii_of_A > 0)
-            std::copy_n(&D[jj * mA], mA, &D[(j2B * nB + j1B) * mA]);
+            std::ranges::copy_n(&D[jj * mA], mA, &D[(j2B * nB + j1B) * mA]);
         }
     }
 }
diff --git a/mex/sources/libkorder/dynamic_m.cc b/mex/sources/libkorder/dynamic_m.cc
index 087186c5a347a6ecf8cb8489f6dc3ba40bba6cfd..4cafa3c36b38f4d103025488ff9e73effdc39170 100644
--- a/mex/sources/libkorder/dynamic_m.cc
+++ b/mex/sources/libkorder/dynamic_m.cc
@@ -73,16 +73,16 @@ DynamicModelMFile::eval(const Vector& y, const Vector& x, const Vector& modParam
                         TensorContainer<FSSparseTensor>& derivatives) noexcept(false)
 {
   mxArray* y_mx = mxCreateDoubleMatrix(y.length(), 1, mxREAL);
-  std::copy_n(y.base(), y.length(), mxGetPr(y_mx));
+  std::ranges::copy_n(y.base(), y.length(), mxGetPr(y_mx));
 
   mxArray* x_mx = mxCreateDoubleMatrix(1, x.length(), mxREAL);
-  std::copy_n(x.base(), x.length(), mxGetPr(x_mx));
+  std::ranges::copy_n(x.base(), x.length(), mxGetPr(x_mx));
 
   mxArray* params_mx = mxCreateDoubleMatrix(modParams.length(), 1, mxREAL);
-  std::copy_n(modParams.base(), modParams.length(), mxGetPr(params_mx));
+  std::ranges::copy_n(modParams.base(), modParams.length(), mxGetPr(params_mx));
 
   mxArray* steady_state_mx = mxCreateDoubleMatrix(ySteady.length(), 1, mxREAL);
-  std::copy_n(ySteady.base(), ySteady.length(), mxGetPr(steady_state_mx));
+  std::ranges::copy_n(ySteady.base(), ySteady.length(), mxGetPr(steady_state_mx));
 
   mxArray *T_order_mx, *T_mx;
 
diff --git a/mex/sources/libkorder/k_ord_dynare.cc b/mex/sources/libkorder/k_ord_dynare.cc
index e1ce47d04cf7f2e1f2bf915f011b951acb70dd18..87dd4c9c2a3764e1f15d3728da8ad8d567bd7082 100644
--- a/mex/sources/libkorder/k_ord_dynare.cc
+++ b/mex/sources/libkorder/k_ord_dynare.cc
@@ -96,9 +96,9 @@ KordpDynare::calcDerivativesAtSteady()
   Vector out(nY);
   out.zeros();
   Vector llxSteady(3 * nY);
-  std::copy_n(ySteady.base(), nY, llxSteady.base());
-  std::copy_n(ySteady.base(), nY, llxSteady.base() + nY);
-  std::copy_n(ySteady.base(), nY, llxSteady.base() + 2 * nY);
+  std::ranges::copy_n(ySteady.base(), nY, llxSteady.base());
+  std::ranges::copy_n(ySteady.base(), nY, llxSteady.base() + nY);
+  std::ranges::copy_n(ySteady.base(), nY, llxSteady.base() + 2 * nY);
 
   dynamicModelFile->eval(llxSteady, xx, params, ySteady, out, dynToDynpp, md);
 }
diff --git a/mex/sources/libkorder/tl/int_sequence.cc b/mex/sources/libkorder/tl/int_sequence.cc
index 709618d07ee8bd4f090ca6a2825e3ef85c5c91a7..09d6435adda8f30338a12e65a4b74c397a859e02 100644
--- a/mex/sources/libkorder/tl/int_sequence.cc
+++ b/mex/sources/libkorder/tl/int_sequence.cc
@@ -85,7 +85,7 @@ IntSequence&
 IntSequence::operator=(const IntSequence& s)
 {
   TL_RAISE_IF(length != s.length, "Wrong length for in-place IntSequence::operator=");
-  std::copy_n(s.data, length, data);
+  std::ranges::copy_n(s.data, length, data);
   return *this;
 }
 
@@ -93,7 +93,7 @@ IntSequence&
 IntSequence::operator=(IntSequence&& s)
 {
   TL_RAISE_IF(length != s.length, "Wrong length for in-place IntSequence::operator=");
-  std::copy_n(s.data, length, data);
+  std::ranges::copy_n(s.data, length, data);
   return *this;
 }
 
diff --git a/mex/sources/libkorder/tl/int_sequence.hh b/mex/sources/libkorder/tl/int_sequence.hh
index 1ae4a575d8423522b7bdee06297581c474b8f328..3c0d0be8d6030dd44610d2d3b2d5a2a314c1cb6c 100644
--- a/mex/sources/libkorder/tl/int_sequence.hh
+++ b/mex/sources/libkorder/tl/int_sequence.hh
@@ -84,7 +84,7 @@ public:
   // Copy constructor
   IntSequence(const IntSequence& s) : data {new int[s.length]}, length {s.length}
   {
-    std::copy_n(s.data, length, data);
+    std::ranges::copy_n(s.data, length, data);
   }
   // Move constructor
   IntSequence(IntSequence&& s) noexcept :
@@ -101,7 +101,7 @@ public:
   // Subsequence constructor (without pointer sharing)
   IntSequence(const IntSequence& s, int i1, int i2) : data {new int[i2 - i1]}, length {i2 - i1}
   {
-    std::copy_n(s.data + i1, length, data);
+    std::ranges::copy_n(s.data + i1, length, data);
   }
   /* Unfolds a given integer sequence with respect to a given symmetry. If for
      example the sequence is (a,b) and the symmetry is (2,3), then the
diff --git a/mex/sources/local_state_space_iterations/local_state_space_iteration_2.cc b/mex/sources/local_state_space_iterations/local_state_space_iteration_2.cc
index 73d08fa645e2fda545aca8956a7f68ac1b3c82e5..5d0b0800b50a81509b5988275979c66a520e4bec 100644
--- a/mex/sources/local_state_space_iterations/local_state_space_iteration_2.cc
+++ b/mex/sources/local_state_space_iterations/local_state_space_iteration_2.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2010-2022 Dynare Team
+ * Copyright © 2010-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -77,8 +77,8 @@ ss2Iteration_pruning(double* y2, double* y1, const double* yhat2, const double*
       int particle_ = particle * m;
       int particle__ = particle * n;
       int particle___ = particle * q;
-      std::copy_n(constant, m, &y2[particle_]);
-      std::copy_n(ss, m, &y1[particle_]);
+      std::ranges::copy_n(constant, m, &y2[particle_]);
+      std::ranges::copy_n(ss, m, &y1[particle_]);
 #ifdef USE_BLAS_AT_FIRST_ORDER
       dgemv("N", &m, &n, &one, ghx, &m, &yhat2[particle__], &ONE, &one, &y2[particle_], &ONE);
       dgemv("N", &m, &q, &one, ghu, &m, &epsilon[particle___], &ONE, &one, &y2[particle_], &ONE);
@@ -156,7 +156,7 @@ ss2Iteration(double* y, const double* yhat, const double* epsilon, const double*
       int particle_ = particle * m;
       int particle__ = particle * n;
       int particle___ = particle * q;
-      std::copy_n(constant, m, &y[particle_]);
+      std::ranges::copy_n(constant, m, &y[particle_]);
 #ifdef USE_BLAS_AT_FIRST_ORDER
       dgemv("N", &m, &n, &one, ghx, &m, &yhat[particle__], &ONE, &one, &y[particle_], &ONE);
       dgemv("N", &m, &q, &one, ghu, &m, &epsilon[particle___], &ONE, &one, &y[particle_], &ONE);
diff --git a/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc b/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc
index 78a5c5a2c053012ccd5cfa3b4e62c03d9a5e7682..0879b6241ff26516a5aecc9c7300b11f7ddf3fe8 100644
--- a/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc
+++ b/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2023 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -108,8 +108,8 @@ DynamicModelDllCaller::DynamicModelDllCaller(size_t ntt, mwIndex ny, mwIndex nx,
 void
 DynamicModelDllCaller::copy_jacobian_column(mwIndex col, double* dest) const
 {
-  std::copy_n(jacobian_p.data() + g1_sparse_colptr[col] - 1,
-              g1_sparse_colptr[col + 1] - g1_sparse_colptr[col], dest);
+  std::ranges::copy_n(jacobian_p.data() + g1_sparse_colptr[col] - 1,
+                      g1_sparse_colptr[col + 1] - g1_sparse_colptr[col], dest);
 }
 
 void
@@ -223,7 +223,7 @@ DynamicModelMatlabCaller::eval(double* resid)
     if (mxIsComplex(plhs[0]))
       plhs[0] = cmplxToReal<false>(plhs[0]);
 
-    std::copy_n(mxGetPr(plhs[0]), mxGetNumberOfElements(plhs[0]), resid);
+    std::ranges::copy_n(mxGetPr(plhs[0]), mxGetNumberOfElements(plhs[0]), resid);
     mxDestroyArray(plhs[0]);
 
     T_order_mx = plhs[1];
diff --git a/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh b/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh
index d4891e57ce427f1a60253c6a02a84b15ea92d975..b651ec59a23f9334cca815bff2595c0023523580 100644
--- a/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh
+++ b/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2023 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -154,8 +154,8 @@ DynamicModelMatlabCaller::cmplxToReal(mxArray* cmplx_mx)
 
   if constexpr (sparse)
     {
-      std::copy_n(mxGetIr(cmplx_mx), mxGetNzmax(cmplx_mx), mxGetIr(real_mx));
-      std::copy_n(mxGetJc(cmplx_mx), mxGetN(cmplx_mx) + 1, mxGetJc(real_mx));
+      std::ranges::copy_n(mxGetIr(cmplx_mx), mxGetNzmax(cmplx_mx), mxGetIr(real_mx));
+      std::ranges::copy_n(mxGetJc(cmplx_mx), mxGetN(cmplx_mx) + 1, mxGetJc(real_mx));
     }
 
 #if MX_HAS_INTERLEAVED_COMPLEX
diff --git a/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc b/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc
index ffd1d59ac0545dc5b2f9f9f75aa70497b3c54709..31b700909fd82852d4149294145d5f493f804b55 100644
--- a/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc
+++ b/mex/sources/perfect_foresight_problem/perfect_foresight_problem.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019-2023 Dynare Team
+ * Copyright © 2019-2024 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -226,22 +226,22 @@ mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
       {
         // Fill vector of dynamic variables
         if (T > 0 && T < periods - 1)
-          std::copy_n(y + (T - 1) * ny, 3 * ny, m->y());
+          std::ranges::copy_n(y + (T - 1) * ny, 3 * ny, m->y());
         else if (T > 0) // Last simulation period
           {
-            std::copy_n(y + (T - 1) * ny, 2 * ny, m->y());
-            std::copy_n(yT, ny, m->y() + 2 * ny);
+            std::ranges::copy_n(y + (T - 1) * ny, 2 * ny, m->y());
+            std::ranges::copy_n(yT, ny, m->y() + 2 * ny);
           }
         else if (T < periods - 1) // First simulation period
           {
-            std::copy_n(y0, ny, m->y());
-            std::copy_n(y + T * ny, 2 * ny, m->y() + ny);
+            std::ranges::copy_n(y0, ny, m->y());
+            std::ranges::copy_n(y + T * ny, 2 * ny, m->y() + ny);
           }
         else // Special case: periods=1 (and so T=0)
           {
-            std::copy_n(y0, ny, m->y());
-            std::copy_n(y, ny, m->y() + ny);
-            std::copy_n(yT, ny, m->y() + 2 * ny);
+            std::ranges::copy_n(y0, ny, m->y());
+            std::ranges::copy_n(y, ny, m->y() + ny);
+            std::ranges::copy_n(yT, ny, m->y() + 2 * ny);
           }
 
         // Fill exogenous
diff --git a/mex/sources/sobol/gaussian.hh b/mex/sources/sobol/gaussian.hh
index 39dfc759a92711c38a0ab29551f40236fb067fd2..3ea364a525d93b4331aa94f5c7200069ea86d4e8 100644
--- a/mex/sources/sobol/gaussian.hh
+++ b/mex/sources/sobol/gaussian.hh
@@ -124,7 +124,7 @@ icdfmSigma(int d, int n, floating_point auto* U, const double* LowerCholSigma)
   icdfm(n * d, U);
   vector<double> tmp(n * d);
   dgemm("N", "N", &dd, &nn, &dd, &one, LowerCholSigma, &dd, U, &dd, &zero, tmp.data(), &dd);
-  copy_n(tmp.begin(), d * n, U);
+  ranges::copy_n(tmp.begin(), d * n, U);
 }
 
 void