Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99246

C++ in Visual Studio Code on MacOS - std::make_unique

$
0
0

I'm running MacOS 10.15 and after many months of rebooting to my BootCamp Win10 with Visual Studio 2019 I decided to try out VS Code with C++ and Code Runner extension. Sadly, I pretty quickly got into troubles with outdated version of C++ that's built in OS (or downloaded with developer tools, I don't know).

I'm trying to run just simple std::make_unique<T> but all I get as a response is

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

This is my code:

#include <memory>
#include <vector>


class Pole{

    Pole(size_t chunk=100): chunk_(chunk), count_(0) {}

    public:
        void push_back(int item){

            if(count_ % chunk_ == 0){
                v_.push_back(std::make_unique< int[]>(chunk_));  //this is the problematic line

            }
            count_++;
            v_[count_/chunk_][count_%chunk_]=item;
        }



    private:
        size_t chunk_;
        size_t count_;

        std::vector<std::unique_ptr<int[]> > v_;

};

I already tried playing with "cppStandard": in c_cpp_properties.json and setting its value to "cppStandard": "c++20", but it did not help.

Thank you!


Viewing all articles
Browse latest Browse all 99246

Trending Articles