Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3491282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:37:05+00:00 2026-05-18T11:37:05+00:00

I redefined some maths functions (so that they’re faster -ie: less accurate-, or use

  • 0

I redefined some maths functions (so that they’re faster -ie: less accurate-, or use templates). I put these functions in a namespace and they work just fine.

It happens often, though, that I forget to call functions from my namespace (ie: I forget to write mymath::cos or using mymath::cos; when I want to call cos), and it’s pretty tough to find out where I forgot it (until now I found it out only by profiling).

Given that

  • I only include standard math.h or cmath headers within my math header, and that
  • I need to include standard math headers (because some of my functions are just wrappers for standard one, and I want them to be inline or they’re templated),

is there a portable way to hide standard math function so that a compile error is reported, if global namespace (ie: without a namespace) math functions are used?

A solution could be putting an using namespace mymath; at the bottom of my math header file, but this solution doesn’t seem that great: it breaks the whole purpose of namespaces; I’d prefer having to explicity say whether to use a function from mymath or from std so that I am forced to choose between a fester or a more accurate function without the risk of forgetting about it.


EDIT:

Many answers say that if I use cos from global namespace (without using std nor mymath), and include cmath (and not math.h), compilation should fail.

I don’t know what the standard says about it, but:

#include <cmath>
int main( ) {
    cos( M_PI );
    return 0;
}

compiles fine with GNU GCC (g++) 4.5.1 (and older versions).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:37:05+00:00Added an answer on May 18, 2026 at 11:37 am

    Put this in a header file, and #include it everywhere:

    namespace DontUseMe {  
    double cos (double) ;  
    // ...etc.  
    }  
    using namespace DontUseMe ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UserControl with some predefined controls (groupbox,button,datagridview) on it, these controls are
I just want my apache to register some of my predefined environment so that
I encountered a problem that took me some time to debug where a plug-in
Is there any way to redefine a class or some of its methods without
I want to ship a default SQLite database, with some predefined key/value pairs in
I get numerous method redefined warnings while running an application under Merb 0.9.3. Of
I have read a lot that LISP can redefine syntax on the fly, presumably
To specialize a class template, one has to redefine all of the member functions
I'm working on a drop in assembly that has predefined pages and usable controls.
I am converting some code from C to C++ in MS dev studio under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.