No member named 'apply' in namespace 'std

I install cling using the instructions here Cling Build Instructions - ROOT. The installation was successful and can use cling anywhere in my bash shell. I created a test script which looks like

//#! /usr/local/bin/cling --metastr=//.

#include <iostream>

using namespace std;

void script(){
    std::cout << "This is a test" << std::endl;

Executing this script in cling works without error. But executing the below script shows the error.


//#! /usr/local/bin/cling --metastr=//.

#include <iostream>

using namespace std;

int script(){
    std::cout << "This is a test" << std::endl;
    return 0;
****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
[cling]$ .x script.cxx
This is a test
In file included from input_line_5:1:
xxxxx/include/cling/Interpreter/RuntimePrintValue.h:249:33: warning: template template parameter using 'typename' is a C++17 extension [-Wc++17-extensions]
  template <template <class...> typename TUPLE, typename... ARGS,
xxxxx/include/cling/Interpreter/RuntimePrintValue.h:260:8: warning: pack fold expression is a C++17 extension [-Wc++17-extensions]
xxxxx/include/cling/Interpreter/RuntimePrintValue.h:263:10: error: no member named 'apply' in namespace 'std'
    std::apply(concatToStr, *val);
(int) 0

I did not try with cling but with root it is ok:

% root
  | Welcome to ROOT 6.31/01               |
  | (c) 1995-2023, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Dec 13 2023, 10:26:08                      |
  | From heads/master@v6-31-01-399-g51c26e882d                       |
  | With Apple clang version 14.0.0 (clang-1400.0.29.202)            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |

root [0] .x script.cxx
This is a test
(int) 0
root [1] 

Dear @cw2636 ,

I think the cling release you downloaded is affected by this PR Revert "[Cling] Simplify std::tuple/pair value printer" by Axel-Naumann · Pull Request #14197 · root-project/root · GitHub . It should be fixed in the latest development branch of ROOT/cling. Can you try by downloading and building the latest cling? Since we also just updated to use LLVM16 as a baseline, this should be the most appropriate build instructions

git clone -b cling-llvm16 src
git clone

The rest is the same as the link you provided. I will also take care of updating those instructions on the website.

Note: make sure you create a completely new build, removing any previous existing installation.


Thank you