0

Is there anything apart from iostreams that cannot be copied and are there any non global workarounds to use them without knowing about pointers and references.

If runtime and memory consumption are not a concern C++11 (with its tuple) apparently reduces the need for knowing about those. I am hoping I can skip them entirely to code C++ for non systems level programs.

Himanshu
  • 2,384
  • 2
  • 24
  • 42
  • `std::unique_ptr` is not copyable, but that, as well as what you mentioned, are moveable. – chris Aug 15 '13 at 02:54
  • 6
    Are you saying you want to code C++ but you don't want to learn about pointers and references? – paddy Aug 15 '13 at 02:55
  • 1
    You should read a [good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) on C++. – Captain Obvlious Aug 15 '13 at 02:58
  • 3
    any class without copy constructor? – Yu Hao Aug 15 '13 at 03:01
  • Thanks @Captain Oblivious for the advice. I am reading one of those. Its a fantastic book updated for C++11. I won't name it here or else someone will judge the book from its readers :) – Himanshu Aug 15 '13 at 03:07
  • 1
    @Himanshu: That's like saying you want to drive but you don't want to learn how to press the gas pedal. – user541686 Aug 15 '13 at 03:11
  • @Himanshu Pointers and references are part of the language, and you really ought to learn how they work and why they exist, even though you might arguably be able to avoid them for a bit longer in C++11. – paddy Aug 15 '13 at 03:15
  • 6
    I got to say, if you don't want to learn about pointers and references, you'll probably be able to write some toy programs, but that's all. – Yu Hao Aug 15 '13 at 03:16
  • This question misses an important point: just because you *can* copy something doesn't mean you *should*. Additionally, if you believe that pointers and references are not worth learning, C++ is probably not for you. – Marc Claesen Aug 15 '13 at 07:08

3 Answers3

3

Basically anything that doesn't have a copy constructor or assignment operator can't be copied and you rarely want a global workaround as they cause endless amounts of problems. So there's no reduction nor skipping of the need to know about pointers and references.

Paul Evans
  • 27,315
  • 3
  • 37
  • 54
  • Technically, primitive types like `int` doesn't have a copy constructor, but they are copy-able. – Yu Hao Aug 15 '13 at 03:24
3

From the top of my head:

std::future
std::mutex
std::lock_guard
std::unique_lock

I'm probably missing many more...

StackedCrooked
  • 34,653
  • 44
  • 154
  • 278
  • 3
    `std::dynarray`, `std::unique_ptr`, `std::thread`, `std::atomic`, `std::condition_variable`.. etc. – Rapptz Aug 15 '13 at 03:58
  • When the time comes that I use those, pointers and references would seem trivial :) Perhaps I can manage w/o them but I may be handicapped. Thanks. – Himanshu Aug 16 '13 at 00:26
1

Trivially, any function, which is why those are always passed around as pointers to functions.

MSalters
  • 173,980
  • 10
  • 155
  • 350