variadic-templates

Chained ostream internal behavior and their results on MSVC (versus Clang)

久未见 提交于 2020-07-09 05:18:16
问题 An issue of streams, internal string, and operation ordering with MSVC versus GCC / Clang Hello everyone, I just recently began to work more seriously with MSVC for a cross-platform project of mine, and while testing outputs via chained STD stream ( ie. a succession of obj.foo() << endl << obj.bar() << endl << [..etc] ) I came across a behavior when using internally updated string neither did I expected nor had encountered on Linux with GCC or Clang . Compiler versions were GCC 7.5, Clang 11

Chained ostream internal behavior and their results on MSVC (versus Clang)

我怕爱的太早我们不能终老 提交于 2020-07-09 05:16:41
问题 An issue of streams, internal string, and operation ordering with MSVC versus GCC / Clang Hello everyone, I just recently began to work more seriously with MSVC for a cross-platform project of mine, and while testing outputs via chained STD stream ( ie. a succession of obj.foo() << endl << obj.bar() << endl << [..etc] ) I came across a behavior when using internally updated string neither did I expected nor had encountered on Linux with GCC or Clang . Compiler versions were GCC 7.5, Clang 11

Clang can't find template binary operator in fold expression

时光怂恿深爱的人放手 提交于 2020-06-27 09:49:13
问题 This is my binary operator to concatenate tuples: template <class... Args1, class... Args2> constexpr decltype(auto) operator+(const std::tuple<Args1...> &tup1, const std::tuple<Args2...> &tup2) { return std::tuple_cat(tup1, tup2); } It works perfectly on both compiler (gcc, clang) with two tuples: template <class Arg1, class Arg2> constexpr decltype(auto) concat_test(Arg1 &&arg1, Arg2 &&arg2) { return arg1 + arg2; } But when I try to use it in fold expression like follows: template <class...

Clang can't find template binary operator in fold expression

房东的猫 提交于 2020-06-27 09:49:05
问题 This is my binary operator to concatenate tuples: template <class... Args1, class... Args2> constexpr decltype(auto) operator+(const std::tuple<Args1...> &tup1, const std::tuple<Args2...> &tup2) { return std::tuple_cat(tup1, tup2); } It works perfectly on both compiler (gcc, clang) with two tuples: template <class Arg1, class Arg2> constexpr decltype(auto) concat_test(Arg1 &&arg1, Arg2 &&arg2) { return arg1 + arg2; } But when I try to use it in fold expression like follows: template <class...

Pass Member Function to Variadic Template Function

早过忘川 提交于 2020-06-26 06:11:53
问题 I have a class with a function called enqueue: template<class T, class... Args> inline auto ThreadPool::enqueue(T && t, Args&&... args) ->std::future<typename std::result_of<T(Args ...)>::type> { using return_type = typename std::result_of<T(Args...)>::type; auto task = std::make_shared<std::packaged_task<return_type()>> ( std::bind(std::forward<T>(t), std::forward<Args>(args)...) ); std::future<return_type> result = task->get_future(); { std::unique_lock<std::mutex> lock(m_mutex); // Don't