Skip to content
Snippets Groups Projects
Commit 8eb8b3c0 authored by Johannes Elmsheuser's avatar Johannes Elmsheuser
Browse files

Merge branch 'pputils.CxxUtils-20240507' into 'main'

CxxUtils: Add some preprocessor utils.

See merge request !71221
parents dcd1bd0d e97877fb
No related branches found
No related tags found
30 merge requests!78241Draft: FPGATrackSim: GenScan code refactor,!78236Draft: Switching Streams https://its.cern.ch/jira/browse/ATR-27417,!78056AFP monitoring: new synchronization and cleaning,!78041AFP monitoring: new synchronization and cleaning,!77990Updating TRT chip masks for L1TRT trigger simulation - ATR-28372,!77733Draft: add new HLT NN JVT, augmented with additional tracking information,!77731Draft: Updates to ZDC reconstruction,!77728Draft: updates to ZDC reconstruction,!77522Draft: sTGC Pad Trigger Emulator,!76725ZdcNtuple: Fix cppcheck warning.,!76611L1CaloFEXByteStream: Fix out-of-bounds array accesses.,!76475Punchthrough AF3 implementation in FastG4,!76474Punchthrough AF3 implementation in FastG4,!76343Draft: MooTrackBuilder: Recalibrate NSW hits in refine method,!75729New implementation of ZDC nonlinear FADC correction.,!75703Draft: Update to HI han config for HLT jets,!75184Draft: Update file heavyions_run.config,!74430Draft: Fixing upper bound for Delayed Jet Triggers,!73963Changing the path of the histograms to "Expert" area,!73875updating ID ART reference plots,!73874AtlasCLHEP_RandomGenerators: Fix cppcheck warnings.,!73449Add muon detectors to DarkJetPEBTLA partial event building,!73343Draft: [TrigEgamma] Add photon ringer chains on bootstrap mechanism,!72336Fixed TRT calibration crash,!72176Draft: Improving L1TopoOnline chain that now gets no-empty plots. Activating it by default,!72012Draft: Separate JiveXMLConfig.py into Config files,!71876Fix MET trigger name in MissingETMonitoring,!71820Draft: Adding new TLA End-Of-Fill (EOF) chains and removing obsolete DIPZ chains,!71279Draft: ATR-29330: Move L1_4J15 and the HLT chains seeded by it in the MC Menu,!71221CxxUtils: Add some preprocessor utils.
......@@ -169,7 +169,7 @@ foreach( test sincos_test ArrayScanner_test Arrayrep_test
FPControl_test LockedPointer_test nodiscard_test span_test
reverse_wrapper_test atomic_bounded_decrement_test
releasing_iterator_test SizedUInt_test UIntConv_test starts_with_test
normalizeFunctionName_test )
normalizeFunctionName_test pputils_test )
atlas_add_test( ${test}
SOURCES test/${test}.cxx
LINK_LIBRARIES CxxUtils TestTools ${Boost_LIBRARIES})
......
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
* Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file CxxUtils/pputils.h
* @author scott snyder <snyder@bnl.gov>
* @date May, 2024
* @brief Preprocessor utilities.
*
* Given an argument list of arbitrary length, @c CXXUTILS_PP_FIRST returns
* a comma followed by the first argument if it exists; otherwise,
* it expands to nothing. @c CXXUTILS_PP_SECOND does the same thing
* for the second argument, and so on through @CXXUTILS_PP_FIFTH.
*
* That is:
*@code
* CXXUTILS_PP_FIRST(a, b, c) -> , a
* CXXUTILS_PP_FIRST() ->
* CXXUTILS_PP_SECOND(a, b, c) -> , b
* CXXUTILS_PP_SECOND(a) ->
@endcode
*
* @c CXXUTILS_PP_ARG1 through @c CXXUTILS_PP_ARG5 are also available
* as synonyms that may be more useful if these are used through the
* expansion of other macros.
*/
#ifndef CXXUTILS_PPARGS_H
#define CXXUTILS_PPARGS_H
#define CXXUTILS_PP_FIRST(...) CXXUTILS_PP_ARG1(__VA_ARGS__)
#define CXXUTILS_PP_ARG1(...) __VA_OPT__(CXXUTILS_PP_ARG1_(__VA_ARGS__))
#define CXXUTILS_PP_ARG1_(A, ...) , A
#define CXXUTILS_PP_SECOND(...) CXXUTILS_PP_ARG2(__VA_ARGS__)
#define CXXUTILS_PP_ARG2(...) __VA_OPT__(CXXUTILS_PP_ARG2_(__VA_ARGS__))
#define CXXUTILS_PP_ARG2_(A, ...) CXXUTILS_PP_ARG1(__VA_ARGS__)
#define CXXUTILS_PP_THIRD(...) CXXUTILS_PP_ARG3(__VA_ARGS__)
#define CXXUTILS_PP_ARG3(...) __VA_OPT__(CXXUTILS_PP_ARG3_(__VA_ARGS__))
#define CXXUTILS_PP_ARG3_(A, ...) CXXUTILS_PP_ARG2(__VA_ARGS__)
#define CXXUTILS_PP_FOURTH(...) CXXUTILS_PP_ARG4(__VA_ARGS__)
#define CXXUTILS_PP_ARG4(...) __VA_OPT__(CXXUTILS_PP_ARG4_(__VA_ARGS__))
#define CXXUTILS_PP_ARG4_(A, ...) CXXUTILS_PP_ARG3(__VA_ARGS__)
#define CXXUTILS_PP_FIFTH(...) CXXUTILS_PP_ARG5(__VA_ARGS__)
#define CXXUTILS_PP_ARG5(...) __VA_OPT__(CXXUTILS_PP_ARG5_(__VA_ARGS__))
#define CXXUTILS_PP_ARG5_(A, ...) CXXUTILS_PP_ARG4(__VA_ARGS__)
#endif // not CXXUTILS_PPARGS_H
CxxUtils/pputils_test
/*
* Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file CxxUtils/test/pputils_test.cxx
* @author scott snyder <snyder@bnl.gov>
* @date May, 2024
* @brief Tests for pputils.
*/
#undef NDEBUG
#include "CxxUtils/pputils.h"
#include <iostream>
#include <cassert>
void check (int exp, int test=0)
{
assert (exp == test);
}
int main()
{
std::cout << "CxxUtils/pputils_test\n";
check (0 CXXUTILS_PP_FIRST());
check (1 CXXUTILS_PP_FIRST(1));
check (1 CXXUTILS_PP_ARG1(1, 2, 3));
check (0 CXXUTILS_PP_SECOND());
check (0 CXXUTILS_PP_SECOND(1));
check (2 CXXUTILS_PP_SECOND(1, 2));
check (2 CXXUTILS_PP_ARG2(1, 2, 3));
check (0 CXXUTILS_PP_THIRD());
check (0 CXXUTILS_PP_THIRD(1));
check (0 CXXUTILS_PP_THIRD(1, 2));
check (3 CXXUTILS_PP_THIRD(1, 2, 3));
check (3 CXXUTILS_PP_ARG3(1, 2, 3, 4));
check (0 CXXUTILS_PP_FOURTH());
check (0 CXXUTILS_PP_FOURTH(1));
check (0 CXXUTILS_PP_FOURTH(1, 2, 3));
check (4 CXXUTILS_PP_FOURTH(1, 2, 3, 4));
check (4 CXXUTILS_PP_ARG4(1, 2, 3, 4, 5));
check (0 CXXUTILS_PP_FIFTH());
check (0 CXXUTILS_PP_FIFTH(1));
check (0 CXXUTILS_PP_FIFTH(1, 2, 3, 4));
check (5 CXXUTILS_PP_FIFTH(1, 2, 3, 4, 5));
check (5 CXXUTILS_PP_ARG5(1, 2, 3, 4, 5, 6));
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment