/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ #pragma once // @lint-ignore-every CLANGTIDY facebook-hte-LocalUncheckedArrayBounds #include #include #include namespace vkcompute { namespace utils { namespace detail { struct CompileTimeEmptyString { operator const std::string&() const { static const std::string empty_string_literal; return empty_string_literal; } operator const char*() const { return ""; } }; template struct CanonicalizeStrTypes { using type = const T&; }; template struct CanonicalizeStrTypes { using type = const char*; }; inline std::ostream& _str(std::ostream& ss) { return ss; } template inline std::ostream& _str(std::ostream& ss, const T& t) { ss << t; return ss; } template <> inline std::ostream& _str( std::ostream& ss, const CompileTimeEmptyString&) { return ss; } template inline std::ostream& _str(std::ostream& ss, const T& t, const Args&... args) { return _str(_str(ss, t), args...); } template struct _str_wrapper final { static std::string call(const Args&... args) { std::ostringstream ss; _str(ss, args...); return ss.str(); } }; template <> struct _str_wrapper<> final { static CompileTimeEmptyString call() { return CompileTimeEmptyString(); } }; } // namespace detail template inline std::string concat_str(const Args&... args) { return detail::_str_wrapper< typename detail::CanonicalizeStrTypes::type...>::call(args...); } } // namespace utils } // namespace vkcompute