4

I'm attempting to use tuple in my program, and for some reason I am not able to simplify the call with a using declaration. For example:

#include <tuple>

using std::tuple;

...

This throws an error when attempting to compile it:

error: no member named 'tuple' in namespace 'std'

I'm able to use using declarations for other things (like std::string, std::get, etc.) just fine. I think I've narrowed it down to a compiler issue, but I don't have control over which compiler I get to use (university server) and I can't find anything online showing a lack of support for this header or anything. Here is my compiler information:

$ clang++ -v

Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Any thoughts? Here's an example of it working elsewhere: http://cpp.sh/5bofm

Isaac Corbrey
  • 553
  • 3
  • 20
  • Are you compiling with standard version set to before C++11? –  Nov 26 '18 at 23:01
  • @eukaryota I'm compiling with default flags except for warnings, so I'm not sure whether that's the case or not – Isaac Corbrey Nov 26 '18 at 23:03
  • 1
    So you can use `std::tuple` in your code, it's just the `using` part that's not working... ? – super Nov 26 '18 at 23:04
  • @super I just commented out `using std::tuple;` and made all of the places I was calling it include the namespace, and it still does not work. This makes me think that `` is not included in this version of LLVM – Isaac Corbrey Nov 26 '18 at 23:08
  • @IsaacCorbrey Try specifying `-std=c++11` on the compiler command line and use the exact code you posted as test (with the three dots removed). Does it still give an error? –  Nov 26 '18 at 23:10
  • @eukaryota That fixed it, thank you! If you wanna put that as an answer I can accept it – Isaac Corbrey Nov 26 '18 at 23:15

1 Answers1

5

Because the include did not give a preprocessor error, it is likely that the tuple header does exist and that this is not a case of a messed-up/out-of-date C++ standard library install.

However tuple not being defined in std is expected for all the C++ standards before C++11.

With a standard installation and without additional flags your Clang's version should be using C++14, however this seems to have been modified by whoever is maintaining that system or some package maintainer.

To make sure you are using the most recent C++ language standard add -std=c++17 to the compiler invocation or at least -std=c++14 if C++17 is too recent for some reason, e.g. compatibility with older compiler installations. In particular if your are coding for a university class, you might want to ask to clarify up to which C++ standard is acceptable to use.