Questions tagged [stdtuple]

Use this tag for questions about the C++ standard library template std::tuple. It represents an ordered, heterogeneous sequence of objects. Also add the tag [c++] when using this tag.

Also see and .

403 questions
2
votes
1 answer

error use of deleted function when trying to pass rvalue to a tuple

Original context: I am trying to pass a tuple of (object, expected_value_of_some_property) to a test function I created a simple class to reproduce the error I am facing: template class Vector { private: size_t m_size; …
Zaki
  • 107
  • 9
2
votes
2 answers

Inherit CTAD constructor

I have derived from std::tuple and but was unable construct the derived class from an initializer list due to issues with class template argument deduction. Is there a better way to construct such a class beyond just giving it an already constructed…
Tom Huntington
  • 2,260
  • 10
  • 20
2
votes
3 answers

From boiler plate code to template implementation

I am implementing a finite state machine where all possible states are stored within a std::tuple. This is a minimum compiling example of the problem I am facing and its godbolt link https://godbolt.org/z/7ToKc3T3W: #include #include…
Pablo
  • 557
  • 3
  • 16
2
votes
1 answer

Support for std::tuple in swig?

When calling a swig generated function returning std::tuple, i get a swig object of that std::tuple. Is there a way to use type-maps or something else to extract the values? I have tried changing the code to std::vector for a small portion of the…
Simon_lb
  • 23
  • 4
2
votes
3 answers

Printing Pairs inside tuple in C++

I am trying to print all the values of pair inside of a tuple, header file template void printPairs(std::tuple t) { for (int i = 0; i <= 4; i++) //the value of 'i' is not usable in a constant expression { …
n9p4
  • 304
  • 8
  • 34
2
votes
4 answers

c++ get std::vector from std::vector>

i want to initialize a const std::vector member variable in the initializer list of a constructor, given a std::vector> constructor argument. The vector should contain all the first tuple items. Is there a one-liner that…
matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76
2
votes
1 answer

How to convert tuple into initializer list

I make large tuple with std::make_tuple function. something like this template QCborArray array(const T&... args) { return {args...}; } but with tuple instead of parameter pack
LightSith
  • 795
  • 12
  • 27
2
votes
1 answer

Return std::tuple containing const-reference in C++11

I have something like this (C++11) std::tuple func() { return std::make_tuple(some_internal_reference, true); } the problem is that in the caller I cannot declare: const MyType& obj; // this does not compile of course bool…
Taw
  • 479
  • 3
  • 15
2
votes
0 answers

Copy elision with tuples

I always had the wrong impression that if I create temporaries in a function that returns a tuple, and use std::forward_as_tuple in the return statement, then there is no copy, just like automatic copy elision for non-tuple return types. How then…
fheshwfq
  • 303
  • 3
  • 11
2
votes
0 answers

no matching function for call to std::get with const tuple ref as argument

I've been trying to make a generic function in order to build a query in SQL. In order to do that, I went and used tuple with variadic template, in order to make the query more generic. This is the code (This is not a final code so understand some…
Guy Ti
  • 21
  • 2
2
votes
1 answer

Forward the same argument to variadic tuple constructor in C++

TL;DR below I am trying to write some C++ code using a package for multicore processing. The package has a nice sender class that I use to send messages between the threads. It looks something like this: // structs provided by the package struct…
student91
  • 213
  • 1
  • 10
2
votes
2 answers

Extract types from std::tuple for a method signature

I am looking for a way to extract the types of an std::tuple to define a method signature. Take the following (contrived) example: template class A { public: typedef RetT ReturnType; typedef…
2
votes
3 answers

enable_if-like SFINAE expression for std::apply

I would like the ability to disable a function if a callable template argument is not callable via std::apply. Perhaps it would help to explain the problem starting with what works. I have this for the regular function call case: template
dsharlet
  • 1,036
  • 1
  • 8
  • 15
2
votes
1 answer

Split an std::tuple on an arbitrary index

I have an std::tuple and I want to split it at an arbitrary compile-time parameter N. I have seen solutions floating around for getting the head and the tail of an std::tuple like here , here or here , but these cannot solve my problem since for me…
2
votes
0 answers

Why is constexpr with std::forward_as_tuple not working?

Why is the following not compiling? This is somehow counter-intuitive (not to say constexpr concepts are confusing): #include int main() { constexpr const int a = 0; static_assert(a == 0, "Wups"); constexpr auto t2 =…
Gabriel
  • 8,990
  • 6
  • 57
  • 101