Repository: sympy/sympy

Issue:
cxxcode doesn't translate nested Min/Max functions to std::calls
```
import sympy as sp
from sympy.printing.codeprinter import cxxcode
cxxcode(sp.Max(sp.Min(sp.Symbol('x'), sp.Symbol('y')), sp.Min(sp.Symbol('u'), sp.Symbol('v'))))
````

returns

`std::max(Min(u, v), std::min(x, y))`

instead of 

`std::max(std::min(u, v), std::min(x, y))`

Discussion:

Patch:
diff --git a/sympy/printing/cxx.py b/sympy/printing/cxx.py
index b973a396bf..59af346981 100644
--- a/sympy/printing/cxx.py
+++ b/sympy/printing/cxx.py
@@ -90,13 +90,15 @@ def _print_Max(self, expr):
         from sympy import Max
         if len(expr.args) == 1:
             return self._print(expr.args[0])
-        return "%smax(%s, %s)" % (self._ns, expr.args[0], self._print(Max(*expr.args[1:])))
+        return "%smax(%s, %s)" % (self._ns, self._print(expr.args[0]),
+                                  self._print(Max(*expr.args[1:])))
 
     def _print_Min(self, expr):
         from sympy import Min
         if len(expr.args) == 1:
             return self._print(expr.args[0])
-        return "%smin(%s, %s)" % (self._ns, expr.args[0], self._print(Min(*expr.args[1:])))
+        return "%smin(%s, %s)" % (self._ns, self._print(expr.args[0]),
+                                  self._print(Min(*expr.args[1:])))
 
     def _print_using(self, expr):
         if expr.alias == none:


Test patch:
diff --git a/sympy/printing/tests/test_cxx.py b/sympy/printing/tests/test_cxx.py
index 6d1a6d0264..889d9cc7e0 100644
--- a/sympy/printing/tests/test_cxx.py
+++ b/sympy/printing/tests/test_cxx.py
@@ -5,7 +5,7 @@
 
 from sympy.testing.pytest import warns_deprecated_sympy
 
-x, y = symbols('x y')
+x, y, u, v = symbols('x y u v')
 
 
 def test_CXX98CodePrinter():
@@ -61,3 +61,9 @@ def test_cxxcode_submodule():
     # Test the compatibility sympy.printing.cxxcode module imports
     with warns_deprecated_sympy():
         import sympy.printing.cxxcode # noqa:F401
+
+def test_cxxcode_nested_minmax():
+    assert cxxcode(Max(Min(x, y), Min(u, v))) \
+        == 'std::max(std::min(u, v), std::min(x, y))'
+    assert cxxcode(Min(Max(x, y), Max(u, v))) \
+        == 'std::min(std::max(u, v), std::max(x, y))'