Repository: conan-io/conan

Issue:
[bug] Conan 2.0.11+ choose wrong default cppstd for apple-clang
### Environment details

* Operating System+version: macOS 13.6
* Compiler+version: apple-clang 14.0
* Conan version: 2.0.11 & 2.0.12
* Python version: 3.11.5


### Steps to reproduce

```
python -m pip install --upgrade conan==2.0.11
conan profile detect --force
```

I believe this is caused by the removal of 
```
    if compiler != "msvc":
        cppstd = _cppstd_default(compiler, version)
        if compiler == "apple-clang" and version >= "11":
            # forced auto-detection, gnu98 is too old
            cppstd = "gnu17"
        result.append(("compiler.cppstd", cppstd))
```
in this commit https://github.com/conan-io/conan/commit/7f6430ad621cc4b4c2871d47686bb4d9993de4fb#diff-054375ca45a4ad879799d84fd9d02d0aae4e517cf4a6be98134ff446712d833d

### Logs

```detect_api: Found apple-clang 14.0
detect_api: apple-clang>=13, using the major as version

Detected profile:
WARN: This profile is a guess of your environment, please check it.
WARN: Defaulted to cppstd='gnu17' for apple-clang.
WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions.
WARN: Use your own profile files for stability.
Saving detected profile to /Users/runner/.conan2/profiles/default
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu98
compiler.libcxx=libc++
compiler.version=14
os=Macos
```


Discussion:

Resolving patch:
diff --git a/conan/internal/api/detect_api.py b/conan/internal/api/detect_api.py
--- a/conan/internal/api/detect_api.py
+++ b/conan/internal/api/detect_api.py
@@ -228,6 +228,16 @@ def _mcst_lcc_cppstd_default(version):
     return default
 
 
+def detect_cppstd(compiler, compiler_version):
+    cppstd = default_cppstd(compiler, compiler_version)
+    if compiler == "apple-clang" and compiler_version >= "11":
+        # Conan does not detect the default cppstd for apple-clang,
+        # because it's still 98 for the compiler (eben though xcode uses newer in projects)
+        # and having it be so old would be annoying for users
+        cppstd = "gnu17"
+    return cppstd
+
+
 def detect_compiler():
     """
     find the default compiler on the build machine
diff --git a/conans/client/conf/detect.py b/conans/client/conf/detect.py
--- a/conans/client/conf/detect.py
+++ b/conans/client/conf/detect.py
@@ -1,6 +1,6 @@
 from conan.api.output import ConanOutput
 from conan.internal.api.detect_api import detect_os, detect_arch, default_msvc_runtime, \
-    detect_libcxx, default_cppstd, detect_compiler, default_compiler_version
+    detect_libcxx, detect_cppstd, detect_compiler, default_compiler_version
 
 
 def detect_defaults_settings():
@@ -31,7 +31,7 @@ def detect_defaults_settings():
     libcxx = detect_libcxx(compiler, version)
     if libcxx:
         result.append(("compiler.libcxx", libcxx))
-    cppstd = default_cppstd(compiler, version)
+    cppstd = detect_cppstd(compiler, version)
     if cppstd:
         result.append(("compiler.cppstd", cppstd))
     result.append(("build_type", "Release"))


Test patch:
diff --git a/conans/test/unittests/tools/build/test_cppstd.py b/conans/test/unittests/tools/build/test_cppstd.py
--- a/conans/test/unittests/tools/build/test_cppstd.py
+++ b/conans/test/unittests/tools/build/test_cppstd.py
@@ -1,7 +1,9 @@
 import pytest
 
+from conan.internal.api.detect_api import detect_cppstd
 from conan.tools.build import supported_cppstd, check_min_cppstd, valid_min_cppstd, default_cppstd
 from conans.errors import ConanException, ConanInvalidConfiguration
+from conans.model.version import Version
 from conans.test.utils.mocks import MockSettings, ConanFileMock
 
 
@@ -25,6 +27,23 @@ def test_supported_cppstd_clang(compiler, compiler_version, values):
     assert sot == values
 
 
+@pytest.mark.parametrize("compiler,compiler_version,result", [
+    ("gcc", "5", 'gnu98'),
+    ("gcc", "8", "gnu14"),
+    ("gcc", "12", "gnu17"),
+    ("msvc", "190", "14"),
+    ("apple-clang", "10.0", "gnu98"),
+    # We diverge from the default cppstd for apple-clang >= 11
+    ("apple-clang", "12.0", "gnu17"),
+    ("clang", "4", "gnu98"),
+    ("clang", "6", "gnu14"),
+    ("clang", "17", "gnu17")
+])
+def test_detected_cppstd(compiler, compiler_version, result):
+    sot = detect_cppstd(compiler, Version(compiler_version))
+    assert sot == result
+
+
 def test_supported_cppstd_with_specific_values():
     settings = MockSettings({})
     conanfile = ConanFileMock(settings)
@@ -104,6 +123,7 @@ def test_supported_cppstd_mcst(compiler, compiler_version, values):
     sot = supported_cppstd(conanfile)
     assert sot == values
 
+
 @pytest.mark.parametrize("compiler,compiler_version,values", [
     ("qcc", "4.4", ['98', 'gnu98']),
     ("qcc", "5.4", ['98', 'gnu98', '11', 'gnu11', "14", "gnu14", "17", "gnu17"]),
@@ -116,20 +136,6 @@ def test_supported_cppstd_qcc(compiler, compiler_version, values):
     assert sot == values
 
 
-@pytest.mark.parametrize("compiler,compiler_version,result", [
-    ("gcc", "5", 'gnu98'),
-    ("gcc", "8", "gnu14"),
-    ("msvc", "190", "14"),
-    ("apple-clang", "12.0", "gnu98"),
-    ("clang", "6", "gnu14"),
-])
-def test_default_cppstd_gcc(compiler, compiler_version, result):
-    settings = MockSettings({"compiler": compiler, "compiler.version": compiler_version})
-    conanfile = ConanFileMock(settings)
-    sot = default_cppstd(conanfile)
-    assert sot == result
-
-
 def test_check_cppstd_type():
     """ cppstd must be a number
     """
diff --git a/conans/test/unittests/util/detect_test.py b/conans/test/unittests/util/detect_test.py
--- a/conans/test/unittests/util/detect_test.py
+++ b/conans/test/unittests/util/detect_test.py
@@ -3,6 +3,7 @@
 
 from parameterized import parameterized
 
+from conan.internal.api.detect_api import detect_cppstd
 from conans.client.conf.detect import detect_defaults_settings
 from conans.model.version import Version
 from conans.test.utils.mocks import RedirectedTestOutput