1

I'm working on a custom library. So far, I've wrapped std::tuple and std::tie into my own myOwn::Tuple and myOwn::tie. They function the same way that std::tuple and std::tie do. I'd like to do something similar with std::ignore.

So far, I've written the following:

namespace myOwn
{
     auto
     tilde()
     -> decltype(std::ignore)
     {
         return std::ignore;
     }
}

My only issue is that I now have to use myOwn::tilde() with parentheses. I'd like to be able to use this as myOwn::tilde. So far, all I've read on std::ignore is how to use it,

Here: Possible implementations of std::ignore

Here: Requirements for std::ignore

And here: C++: Return type of std::tie with std::ignore

I've tried using

typedef std::ignore tilde

but this was not successful. Any help would be appreciated. This question could useful to anyone else trying to wrap objects.

Community
  • 1
  • 1
Luis Negrete
  • 43
  • 1
  • 6

1 Answers1

5

If you do not need to modify std::ignore, and simply want to rename it, then

decltype(std::ignore) &tilde = std::ignore;

at namespace scope should do what you need.

std::ignore is not guaranteed to be DefaultConstructible or CopyAssignable, so it cannot be portably constructed or copied, but we can save a reference to it. The type of this tilde is decltype(std::ignore) &, but since std::tie takes references, this should function the same as std::ignore.

Chaos
  • 335
  • 1
  • 6