<commit_before>
def try_compile(compiler, code=None, flags=[], ext='.cpp'):
    """Returns True if the compiler is able to compile the given code"""
    import tempfile
    from distutils.errors import CompileError
    import os

    code = code or 'int main (int argc, char **argv) { return 0; }'

    with tempfile.TemporaryDirectory() as temp_dir:
        fname = os.path.join(temp_dir, 'main'+ext)
        with open(fname, 'w') as f:
            f.write(code)

        try:
            compiler.compile([fname], extra_postargs=flags)
        except CompileError:
            return False
    return True


def has_flag(compiler, flag):
    return try_compile(compiler, flags=[flag])


def get_std_flag(compiler):
    # Test the compiler for the highest available c++ standard flag<commit_msg>BLD: Divert output from test compiles into a temporary directory<commit_after>
def try_compile(compiler, code=None, flags=[], ext='.cpp'):
    """Returns True if the compiler is able to compile the given code"""
    import tempfile
    from distutils.errors import CompileError
    import os

    code = code or 'int main (int argc, char **argv) { return 0; }'

    with tempfile.TemporaryDirectory() as temp_dir:
        fname = os.path.join(temp_dir, 'main'+ext)
        with open(fname, 'w') as f:
            f.write(code)

        try:
            compiler.compile([fname], output_dir=temp_dir, extra_postargs=flags)
        except CompileError:
            return False
    return True


def has_flag(compiler, flag):
    return try_compile(compiler, flags=[flag])


def get_std_flag(compiler):
    # Test the compiler for the highest available c++ standard flag
{'fraction_non_alphanumeric': 0.10036057692307693, 'fraction_numerical': 0.001201923076923077, 'mean_word_length': 3.0709046454767726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1438390', 'n_tokens_mistral': 491, 'n_tokens_neox': 477, 'n_words': 163}