Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ says gcd is not a member of std

I am using visual studio 2017 and I have run across a problem. When trying to use std::gcd it gives me an error error C2039: 'gcd': is not a member of 'std'

Here's my code:

#include "pch.h"
#include <iostream>
#include <numeric>

int main() {
    std::cout << std::gcd(10, 5);
    return 1;
}
like image 597
Joyal Mathew Avatar asked Oct 19 '25 08:10

Joyal Mathew


1 Answers

std::gcd was added in C++17. To use it in Visual Studio you need to specify the language standard. You can do that two ways, use the /std:c++17 command-line option or in the Project Properties dialog: C/C++ -> Language -> C++ Language Standard.

like image 146
Blastfurnace Avatar answered Oct 21 '25 23:10

Blastfurnace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!